| @@ -563,7 +563,6 @@ out: · 562 unmodified lines |
| 563 | 563 | |
| 564 | 564 | static int mctp_dst_output(struct mctp_dst *dst, struct sk_buff *skb) |
| 565 | 565 | { |
| 566 | | − struct mctp_hdr *hdr = mctp_hdr(skb); |
| 567 | 566 | char daddr_buf[MAX_ADDR_LEN]; |
| 568 | 567 | char *daddr = NULL; |
| 569 | 568 | int rc; |
| @@ -586,7 +585,7 @@ static int mctp_dst_output(struct mctp_dst *dst, struct sk_buff *skb) · 16 unmodified lines |
| 586 | 585 | daddr = dst->haddr; |
| 587 | 586 | } else { |
| 588 | 587 | /* If lookup fails let the device handle daddr==NULL */ |
| 589 | | − if (mctp_neigh_lookup(dst->dev, hdr->dest, daddr_buf) == 0) |
| 588 | + if (mctp_neigh_lookup(dst->dev, dst->nexthop, daddr_buf) == 0) |
| 590 | 589 | daddr = daddr_buf; |
| 591 | 590 | } |
| 592 | 591 | |
| @@ -610,7 +609,8 @@ static int mctp_dst_output(struct mctp_dst *dst, struct sk_buff *skb) · 17 unmodified lines |
| 610 | 609 | static void mctp_route_release(struct mctp_route *rt) |
| 611 | 610 | { |
| 612 | 611 | if (refcount_dec_and_test(&rt->refs)) { |
| 613 | | − mctp_dev_put(rt->dev); |
| 612 | + if (rt->dst_type == MCTP_ROUTE_DIRECT) |
| 613 | + mctp_dev_put(rt->dev); |
| 614 | 614 | kfree_rcu(rt, rcu); |
| 615 | 615 | } |
| 616 | 616 | } |
| @@ -799,10 +799,16 @@ static struct mctp_sk_key *mctp_lookup_prealloc_tag(struct mctp_sock *msk, · 182 unmodified lines |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /* routing lookups */ |
| 802 | +static unsigned int mctp_route_netid(struct mctp_route *rt) |
| 803 | +{ |
| 804 | + return rt->dst_type == MCTP_ROUTE_DIRECT ? |
| 805 | + READ_ONCE(rt->dev->net) : rt->gateway.net; |
| 806 | +} |
| 807 | + |
| 802 | 808 | static bool mctp_rt_match_eid(struct mctp_route *rt, |
| 803 | 809 | unsigned int net, mctp_eid_t eid) |
| 804 | 810 | { |
| 805 | | − return READ_ONCE(rt->dev->net) == net && |
| 811 | + return mctp_route_netid(rt) == net && |
| 806 | 812 | rt->min <= eid && rt->max >= eid; |
| 807 | 813 | } |
| 808 | 814 | |
| @@ -811,16 +817,21 @@ static bool mctp_rt_compare_exact(struct mctp_route *rt1, · 2 unmodified lines |
| 811 | 817 | struct mctp_route *rt2) |
| 812 | 818 | { |
| 813 | 819 | ASSERT_RTNL(); |
| 814 | | − return rt1->dev->net == rt2->dev->net && |
| 820 | + return mctp_route_netid(rt1) == mctp_route_netid(rt2) && |
| 815 | 821 | rt1->min == rt2->min && |
| 816 | 822 | rt1->max == rt2->max; |
| 817 | 823 | } |
| 818 | 824 | |
| 819 | | −static void mctp_dst_from_route(struct mctp_dst *dst, struct mctp_route *route) |
| 825 | +/* must only be called on a direct route, as the final output hop */ |
| 826 | +static void mctp_dst_from_route(struct mctp_dst *dst, mctp_eid_t eid, |
| 827 | + unsigned int mtu, struct mctp_route *route) |
| 820 | 828 | { |
| 821 | 829 | mctp_dev_hold(route->dev); |
| 830 | + dst->nexthop = eid; |
| 822 | 831 | dst->dev = route->dev; |
| 823 | | − dst->mtu = route->mtu ?: READ_ONCE(dst->dev->dev->mtu); |
| 832 | + dst->mtu = READ_ONCE(dst->dev->dev->mtu); |
| 833 | + if (mtu) |
| 834 | + dst->mtu = min(dst->mtu, mtu); |
| 824 | 835 | dst->halen = 0; |
| 825 | 836 | dst->output = route->output; |
| 826 | 837 | } |
| @@ -854,6 +865,7 @@ int mctp_dst_from_extaddr(struct mctp_dst *dst, struct net *net, int ifindex, · 27 unmodified lines |
| 854 | 865 | dst->mtu = READ_ONCE(netdev->mtu); |
| 855 | 866 | dst->halen = halen; |
| 856 | 867 | dst->output = mctp_dst_output; |
| 868 | + dst->nexthop = 0; |
| 857 | 869 | memcpy(dst->haddr, haddr, halen); |
| 858 | 870 | |
| 859 | 871 | rc = 0; |
| @@ -868,24 +880,54 @@ void mctp_dst_release(struct mctp_dst *dst) · 8 unmodified lines |
| 868 | 880 | mctp_dev_put(dst->dev); |
| 869 | 881 | } |
| 870 | 882 | |
| 883 | +static struct mctp_route *mctp_route_lookup_single(struct net *net, |
| 884 | + unsigned int dnet, |
| 885 | + mctp_eid_t daddr) |
| 886 | +{ |
| 887 | + struct mctp_route *rt; |
| 888 | + |
| 889 | + list_for_each_entry_rcu(rt, &net->mctp.routes, list) { |
| 890 | + if (mctp_rt_match_eid(rt, dnet, daddr)) |
| 891 | + return rt; |
| 892 | + } |
| 893 | + |
| 894 | + return NULL; |
| 895 | +} |
| 896 | + |
| 871 | 897 | /* populates *dst on successful lookup, if set */ |
| 872 | 898 | int mctp_route_lookup(struct net *net, unsigned int dnet, |
| 873 | 899 | mctp_eid_t daddr, struct mctp_dst *dst) |
| 874 | 900 | { |
| 901 | + const unsigned int max_depth = 32; |
| 902 | + unsigned int depth, mtu = 0; |
| 875 | 903 | int rc = -EHOSTUNREACH; |
| 876 | | − struct mctp_route *rt; |
| 877 | 904 | |
| 878 | 905 | rcu_read_lock(); |
| 879 | 906 | |
| 880 | | − list_for_each_entry_rcu(rt, &net->mctp.routes, list) { |
| 881 | | − /* TODO: add metrics */ |
| 882 | | − if (!mctp_rt_match_eid(rt, dnet, daddr)) |
| 883 | | − continue; |
| 907 | + for (depth = 0; depth < max_depth; depth++) { |
| 908 | + struct mctp_route *rt; |
| 884 | 909 | |
| 885 | | − if (dst) |
| 886 | | − mctp_dst_from_route(dst, rt); |
| 887 | | − rc = 0; |
| 888 | | − break; |
| 910 | + rt = mctp_route_lookup_single(net, dnet, daddr); |
| 911 | + if (!rt) |
| 912 | + break; |
| 913 | + |
| 914 | + /* clamp mtu to the smallest in the path, allowing 0 |
| 915 | + * to specify no restrictions |
| 916 | + */ |
| 917 | + if (mtu && rt->mtu) |
| 918 | + mtu = min(mtu, rt->mtu); |
| 919 | + else |
| 920 | + mtu = mtu ?: rt->mtu; |
| 921 | + |
| 922 | + if (rt->dst_type == MCTP_ROUTE_DIRECT) { |
| 923 | + if (dst) |
| 924 | + mctp_dst_from_route(dst, daddr, mtu, rt); |
| 925 | + rc = 0; |
| 926 | + break; |
| 927 | + |
| 928 | + } else if (rt->dst_type == MCTP_ROUTE_GATEWAY) { |
| 929 | + daddr = rt->gateway.eid; |
| 930 | + } |
| 889 | 931 | } |
| 890 | 932 | |
| 891 | 933 | rcu_read_unlock(); |
| @@ -902,10 +944,13 @@ static int mctp_route_lookup_null(struct net *net, struct net_device *dev, · 10 unmodified lines |
| 902 | 944 | rcu_read_lock(); |
| 903 | 945 | |
| 904 | 946 | list_for_each_entry_rcu(rt, &net->mctp.routes, list) { |
| 905 | | − if (rt->dev->dev != dev || rt->type != RTN_LOCAL) |
| 947 | + if (rt->dst_type != MCTP_ROUTE_DIRECT || rt->type != RTN_LOCAL) |
| 948 | + continue; |
| 949 | + |
| 950 | + if (rt->dev->dev != dev) |
| 906 | 951 | continue; |
| 907 | 952 | |
| 908 | | − mctp_dst_from_route(dst, rt); |
| 953 | + mctp_dst_from_route(dst, 0, 0, rt); |
| 909 | 954 | rc = 0; |
| 910 | 955 | break; |
| 911 | 956 | } |
| @@ -1085,11 +1130,6 @@ out_release: · 173 unmodified lines |
| 1085 | 1130 | return rc; |
| 1086 | 1131 | } |
| 1087 | 1132 | |
| 1088 | | −static unsigned int mctp_route_netid(struct mctp_route *rt) |
| 1089 | | −{ |
| 1090 | | − return rt->dev->net; |
| 1091 | | −} |
| 1092 | | − |
| 1093 | 1133 | /* route management */ |
| 1094 | 1134 | |
| 1095 | 1135 | /* mctp_route_add(): Add the provided route, previously allocated via |
| @@ -1097,9 +1137,9 @@ static unsigned int mctp_route_netid(struct mctp_route *rt) · 1 unmodified line |
| 1097 | 1137 | * hold on rt->dev for usage in the route table. On failure a caller will want |
| 1098 | 1138 | * to mctp_route_release(). |
| 1099 | 1139 | * |
| 1100 | | − * We expect that the caller has set rt->type, rt->min, rt->max, rt->dev and |
| 1101 | | − * rt->mtu, and that the route holds a reference to rt->dev (via mctp_dev_hold). |
| 1102 | | − * Other fields will be populated. |
| 1140 | + * We expect that the caller has set rt->type, rt->dst_type, rt->min, rt->max, |
| 1141 | + * rt->mtu and either rt->dev (with a reference held appropriately) or |
| 1142 | + * rt->gateway. Other fields will be populated. |
| 1103 | 1143 | */ |
| 1104 | 1144 | static int mctp_route_add(struct net *net, struct mctp_route *rt) |
| 1105 | 1145 | { |
| @@ -1108,7 +1148,10 @@ static int mctp_route_add(struct net *net, struct mctp_route *rt) · 2 unmodified lines |
| 1108 | 1148 | if (!mctp_address_unicast(rt->min) || !mctp_address_unicast(rt->max)) |
| 1109 | 1149 | return -EINVAL; |
| 1110 | 1150 | |
| 1111 | | − if (!rt->dev) |
| 1151 | + if (rt->dst_type == MCTP_ROUTE_DIRECT && !rt->dev) |
| 1152 | + return -EINVAL; |
| 1153 | + |
| 1154 | + if (rt->dst_type == MCTP_ROUTE_GATEWAY && !rt->gateway.eid) |
| 1112 | 1155 | return -EINVAL; |
| 1113 | 1156 | |
| 1114 | 1157 | switch (rt->type) { |
| @@ -1177,6 +1220,7 @@ int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr) · 62 unmodified lines |
| 1177 | 1220 | |
| 1178 | 1221 | rt->min = addr; |
| 1179 | 1222 | rt->max = addr; |
| 1223 | + rt->dst_type = MCTP_ROUTE_DIRECT; |
| 1180 | 1224 | rt->dev = mdev; |
| 1181 | 1225 | rt->type = RTN_LOCAL; |
| 1182 | 1226 | |
| @@ -1203,7 +1247,7 @@ void mctp_route_remove_dev(struct mctp_dev *mdev) · 20 unmodified lines |
| 1203 | 1247 | |
| 1204 | 1248 | ASSERT_RTNL(); |
| 1205 | 1249 | list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { |
| 1206 | | − if (rt->dev == mdev) { |
| 1250 | + if (rt->dst_type == MCTP_ROUTE_DIRECT && rt->dev == mdev) { |
| 1207 | 1251 | list_del_rcu(&rt->list); |
| 1208 | 1252 | /* TODO: immediate RTM_DELROUTE */ |
| 1209 | 1253 | mctp_route_release(rt); |
| @@ -1296,21 +1340,28 @@ static const struct nla_policy rta_mctp_policy[RTA_MAX + 1] = { · 86 unmodified lines |
| 1296 | 1340 | [RTA_DST] = { .type = NLA_U8 }, |
| 1297 | 1341 | [RTA_METRICS] = { .type = NLA_NESTED }, |
| 1298 | 1342 | [RTA_OIF] = { .type = NLA_U32 }, |
| 1343 | + [RTA_GATEWAY] = NLA_POLICY_EXACT_LEN(sizeof(struct mctp_fq_addr)), |
| 1299 | 1344 | }; |
| 1300 | 1345 | |
| 1301 | 1346 | static const struct nla_policy rta_metrics_policy[RTAX_MAX + 1] = { |
| 1302 | 1347 | [RTAX_MTU] = { .type = NLA_U32 }, |
| 1303 | 1348 | }; |
| 1304 | 1349 | |
| 1305 | | −/* base parsing; common to both _lookup and _populate variants */ |
| 1350 | +/* base parsing; common to both _lookup and _populate variants. |
| 1351 | + * |
| 1352 | + * For gateway routes (which have a RTA_GATEWAY, and no RTA_OIF), we populate |
| 1353 | + * *gatweayp. for direct routes (RTA_OIF, no RTA_GATEWAY), we populate *mdev. |
| 1354 | + */ |
| 1306 | 1355 | static int mctp_route_nlparse_common(struct net *net, struct nlmsghdr *nlh, |
| 1307 | 1356 | struct netlink_ext_ack *extack, |
| 1308 | 1357 | struct nlattr **tb, struct rtmsg **rtm, |
| 1309 | 1358 | struct mctp_dev **mdev, |
| 1359 | + struct mctp_fq_addr *gatewayp, |
| 1310 | 1360 | mctp_eid_t *daddr_start) |
| 1311 | 1361 | { |
| 1362 | + struct mctp_fq_addr *gateway = NULL; |
| 1363 | + unsigned int ifindex = 0; |
| 1312 | 1364 | struct net_device *dev; |
| 1313 | | − unsigned int ifindex; |
| 1314 | 1365 | int rc; |
| 1315 | 1366 | |
| 1316 | 1367 | rc = nlmsg_parse(nlh, sizeof(struct rtmsg), tb, RTA_MAX, |
| @@ -1326,11 +1377,44 @@ static int mctp_route_nlparse_common(struct net *net, struct nlmsghdr *nlh, · 9 unmodified lines |
| 1326 | 1377 | } |
| 1327 | 1378 | *daddr_start = nla_get_u8(tb[RTA_DST]); |
| 1328 | 1379 | |
| 1329 | | − if (!tb[RTA_OIF]) { |
| 1330 | | − NL_SET_ERR_MSG(extack, "ifindex missing"); |
| 1380 | + if (tb[RTA_OIF]) |
| 1381 | + ifindex = nla_get_u32(tb[RTA_OIF]); |
| 1382 | + |
| 1383 | + if (tb[RTA_GATEWAY]) |
| 1384 | + gateway = nla_data(tb[RTA_GATEWAY]); |
| 1385 | + |
| 1386 | + if (ifindex && gateway) { |
| 1387 | + NL_SET_ERR_MSG(extack, |
| 1388 | + "cannot specify both ifindex and gateway"); |
| 1389 | + return -EINVAL; |
| 1390 | + |
| 1391 | + } else if (ifindex) { |
| 1392 | + dev = __dev_get_by_index(net, ifindex); |
| 1393 | + if (!dev) { |
| 1394 | + NL_SET_ERR_MSG(extack, "bad ifindex"); |
| 1395 | + return -ENODEV; |
| 1396 | + } |
| 1397 | + *mdev = mctp_dev_get_rtnl(dev); |
| 1398 | + if (!*mdev) |
| 1399 | + return -ENODEV; |
| 1400 | + gatewayp->eid = 0; |
| 1401 | + |
| 1402 | + } else if (gateway) { |
| 1403 | + if (!mctp_address_unicast(gateway->eid)) { |
| 1404 | + NL_SET_ERR_MSG(extack, "bad gateway"); |
| 1405 | + return -EINVAL; |
| 1406 | + } |
| 1407 | + |
| 1408 | + gatewayp->eid = gateway->eid; |
| 1409 | + gatewayp->net = gateway->net != MCTP_NET_ANY ? |
| 1410 | + gateway->net : |
| 1411 | + READ_ONCE(net->mctp.default_net); |
| 1412 | + *mdev = NULL; |
| 1413 | + |
| 1414 | + } else { |
| 1415 | + NL_SET_ERR_MSG(extack, "no route output provided"); |
| 1331 | 1416 | return -EINVAL; |
| 1332 | 1417 | } |
| 1333 | | − ifindex = nla_get_u32(tb[RTA_OIF]); |
| 1334 | 1418 | |
| 1335 | 1419 | *rtm = nlmsg_data(nlh); |
| 1336 | 1420 | if ((*rtm)->rtm_family != AF_MCTP) { |
| @@ -1343,16 +1427,6 @@ static int mctp_route_nlparse_common(struct net *net, struct nlmsghdr *nlh, · 6 unmodified lines |
| 1343 | 1427 | return -EINVAL; |
| 1344 | 1428 | } |
| 1345 | 1429 | |
| 1346 | | − dev = __dev_get_by_index(net, ifindex); |
| 1347 | | − if (!dev) { |
| 1348 | | − NL_SET_ERR_MSG(extack, "bad ifindex"); |
| 1349 | | − return -ENODEV; |
| 1350 | | − } |
| 1351 | | − |
| 1352 | | − *mdev = mctp_dev_get_rtnl(dev); |
| 1353 | | − if (!*mdev) |
| 1354 | | − return -ENODEV; |
| 1355 | | − |
| 1356 | 1430 | return 0; |
| 1357 | 1431 | } |
| 1358 | 1432 | |
| @@ -1366,24 +1440,34 @@ static int mctp_route_nlparse_lookup(struct net *net, struct nlmsghdr *nlh, · 7 unmodified lines |
| 1366 | 1440 | unsigned int *daddr_extent) |
| 1367 | 1441 | { |
| 1368 | 1442 | struct nlattr *tb[RTA_MAX + 1]; |
| 1443 | + struct mctp_fq_addr gw; |
| 1369 | 1444 | struct mctp_dev *mdev; |
| 1370 | 1445 | struct rtmsg *rtm; |
| 1371 | 1446 | int rc; |
| 1372 | 1447 | |
| 1373 | 1448 | rc = mctp_route_nlparse_common(net, nlh, extack, tb, &rtm, |
| 1374 | | − &mdev, daddr_start); |
| 1449 | + &mdev, &gw, daddr_start); |
| 1375 | 1450 | if (rc) |
| 1376 | 1451 | return rc; |
| 1377 | 1452 | |
| 1378 | | − *netid = mdev->net; |
| 1453 | + if (mdev) { |
| 1454 | + *netid = mdev->net; |
| 1455 | + } else if (gw.eid) { |
| 1456 | + *netid = gw.net; |
| 1457 | + } else { |
| 1458 | + /* bug: _nlparse_common should not allow this */ |
| 1459 | + return -1; |
| 1460 | + } |
| 1461 | + |
| 1379 | 1462 | *type = rtm->rtm_type; |
| 1380 | 1463 | *daddr_extent = rtm->rtm_dst_len; |
| 1381 | 1464 | |
| 1382 | 1465 | return 0; |
| 1383 | 1466 | } |
| 1384 | 1467 | |
| 1385 | | −/* Full route parse for RTM_NEWROUTE: populate @rt. On success, the route will |
| 1386 | | − * hold a reference to the dev. |
| 1468 | +/* Full route parse for RTM_NEWROUTE: populate @rt. On success, |
| 1469 | + * MCTP_ROUTE_DIRECT routes (ie, those with a direct dev) will hold a reference |
| 1470 | + * to that dev. |
| 1387 | 1471 | */ |
| 1388 | 1472 | static int mctp_route_nlparse_populate(struct net *net, struct nlmsghdr *nlh, |
| 1389 | 1473 | struct netlink_ext_ack *extack, |
| @@ -1392,6 +1476,7 @@ static int mctp_route_nlparse_populate(struct net *net, struct nlmsghdr *nlh, · 2 unmodified lines |
| 1392 | 1476 | struct nlattr *tbx[RTAX_MAX + 1]; |
| 1393 | 1477 | struct nlattr *tb[RTA_MAX + 1]; |
| 1394 | 1478 | unsigned int daddr_extent; |
| 1479 | + struct mctp_fq_addr gw; |
| 1395 | 1480 | mctp_eid_t daddr_start; |
| 1396 | 1481 | struct mctp_dev *dev; |
| 1397 | 1482 | struct rtmsg *rtm; |
| @@ -1399,7 +1484,7 @@ static int mctp_route_nlparse_populate(struct net *net, struct nlmsghdr *nlh, · 1 unmodified line |
| 1399 | 1484 | int rc; |
| 1400 | 1485 | |
| 1401 | 1486 | rc = mctp_route_nlparse_common(net, nlh, extack, tb, &rtm, |
| 1402 | | − &dev, &daddr_start); |
| 1487 | + &dev, &gw, &daddr_start); |
| 1403 | 1488 | if (rc) |
| 1404 | 1489 | return rc; |
| 1405 | 1490 | |
| @@ -1425,8 +1510,15 @@ static int mctp_route_nlparse_populate(struct net *net, struct nlmsghdr *nlh, · 19 unmodified lines |
| 1425 | 1510 | rt->min = daddr_start; |
| 1426 | 1511 | rt->max = daddr_start + daddr_extent; |
| 1427 | 1512 | rt->mtu = mtu; |
| 1428 | | − rt->dev = dev; |
| 1429 | | − mctp_dev_hold(rt->dev); |
| 1513 | + if (gw.eid) { |
| 1514 | + rt->dst_type = MCTP_ROUTE_GATEWAY; |
| 1515 | + rt->gateway.eid = gw.eid; |
| 1516 | + rt->gateway.net = gw.net; |
| 1517 | + } else { |
| 1518 | + rt->dst_type = MCTP_ROUTE_DIRECT; |
| 1519 | + rt->dev = dev; |
| 1520 | + mctp_dev_hold(rt->dev); |
| 1521 | + } |
| 1430 | 1522 | |
| 1431 | 1523 | return 0; |
| 1432 | 1524 | } |
| @@ -1446,7 +1538,8 @@ static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, · 13 unmodified lines |
| 1446 | 1538 | if (rc < 0) |
| 1447 | 1539 | goto err_free; |
| 1448 | 1540 | |
| 1449 | | − if (rt->dev->dev->flags & IFF_LOOPBACK) { |
| 1541 | + if (rt->dst_type == MCTP_ROUTE_DIRECT && |
| 1542 | + rt->dev->dev->flags & IFF_LOOPBACK) { |
| 1450 | 1543 | NL_SET_ERR_MSG(extack, "no routes to loopback"); |
| 1451 | 1544 | rc = -EINVAL; |
| 1452 | 1545 | goto err_free; |
| @@ -1505,7 +1598,6 @@ static int mctp_fill_rtinfo(struct sk_buff *skb, struct mctp_route *rt, · 52 unmodified lines |
| 1505 | 1598 | hdr->rtm_tos = 0; |
| 1506 | 1599 | hdr->rtm_table = RT_TABLE_DEFAULT; |
| 1507 | 1600 | hdr->rtm_protocol = RTPROT_STATIC; /* everything is user-defined */ |
| 1508 | | − hdr->rtm_scope = RT_SCOPE_LINK; /* TODO: scope in mctp_route? */ |
| 1509 | 1601 | hdr->rtm_type = rt->type; |
| 1510 | 1602 | |
| 1511 | 1603 | if (nla_put_u8(skb, RTA_DST, rt->min)) |
| @@ -1522,13 +1614,17 @@ static int mctp_fill_rtinfo(struct sk_buff *skb, struct mctp_route *rt, · 10 unmodified lines |
| 1522 | 1614 | |
| 1523 | 1615 | nla_nest_end(skb, metrics); |
| 1524 | 1616 | |
| 1525 | | − if (rt->dev) { |
| 1617 | + if (rt->dst_type == MCTP_ROUTE_DIRECT) { |
| 1618 | + hdr->rtm_scope = RT_SCOPE_LINK; |
| 1526 | 1619 | if (nla_put_u32(skb, RTA_OIF, rt->dev->dev->ifindex)) |
| 1527 | 1620 | goto cancel; |
| 1621 | + } else if (rt->dst_type == MCTP_ROUTE_GATEWAY) { |
| 1622 | + hdr->rtm_scope = RT_SCOPE_UNIVERSE; |
| 1623 | + if (nla_put(skb, RTA_GATEWAY, |
| 1624 | + sizeof(rt->gateway), &rt->gateway)) |
| 1625 | + goto cancel; |
| 1528 | 1626 | } |
| 1529 | 1627 | |
| 1530 | | − /* TODO: conditional neighbour physaddr? */ |
| 1531 | | − |
| 1532 | 1628 | nlmsg_end(skb, nlh); |
| 1533 | 1629 | |
| 1534 | 1630 | return 0; |