summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index f3a255fd29..29a341abbd 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -467,6 +467,8 @@ static uint8_t parse_multipath_nexthops_unicast(ns_id_t ns_id,
nh = nexthop_from_ifindex(index, nh_vrf_id);
if (nh) {
+ nh->weight = rtnh->rtnh_hops + 1;
+
if (num_labels)
nexthop_add_labels(nh, ZEBRA_LSP_STATIC,
num_labels, labels);
@@ -785,34 +787,10 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
} else {
if (!tb[RTA_MULTIPATH]) {
struct nexthop nh;
- size_t sz = (afi == AFI_IP) ? 4 : 16;
-
- memset(&nh, 0, sizeof(nh));
- if (bh_type == BLACKHOLE_UNSPEC) {
- if (index && !gate)
- nh.type = NEXTHOP_TYPE_IFINDEX;
- else if (index && gate)
- nh.type =
- (afi == AFI_IP)
- ? NEXTHOP_TYPE_IPV4_IFINDEX
- : NEXTHOP_TYPE_IPV6_IFINDEX;
- else if (!index && gate)
- nh.type =
- (afi == AFI_IP)
- ? NEXTHOP_TYPE_IPV4
- : NEXTHOP_TYPE_IPV6;
- else {
- nh.type =
- NEXTHOP_TYPE_BLACKHOLE;
- nh.bh_type = BLACKHOLE_UNSPEC;
- }
- } else {
- nh.type = NEXTHOP_TYPE_BLACKHOLE;
- nh.bh_type = bh_type;
- }
- nh.ifindex = index;
- if (gate)
- memcpy(&nh.gate, gate, sz);
+
+ nh = parse_nexthop_unicast(
+ ns_id, rtm, tb, bh_type, index, prefsrc,
+ gate, afi, vrf_id);
rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0,
flags, &p, &src_p, &nh, 0, table,
metric, distance, true);
@@ -1419,6 +1397,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
"nexthop via if %u",
routedesc, nexthop->ifindex);
}
+
+ if (nexthop->weight)
+ rtnh->rtnh_hops = nexthop->weight - 1;
}
static inline void _netlink_mpls_build_singlepath(const char *routedesc,
@@ -1921,7 +1902,7 @@ static void _netlink_nexthop_build_group(struct nlmsghdr *n, size_t req_size,
if (count) {
for (int i = 0; i < count; i++) {
grp[i].id = z_grp[i].id;
- grp[i].weight = z_grp[i].weight;
+ grp[i].weight = z_grp[i].weight - 1;
if (IS_ZEBRA_DEBUG_KERNEL) {
if (i == 0)
@@ -2039,6 +2020,9 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx)
addattr32(&req.n, req_size, NHA_OIF, nh->ifindex);
+ if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_ONLINK))
+ req.nhm.nh_flags |= RTNH_F_ONLINK;
+
num_labels =
build_label_stack(nh->nh_label, out_lse,
label_buf, sizeof(label_buf));
@@ -2347,7 +2331,7 @@ static int netlink_nexthop_process_group(struct rtattr **tb,
for (int i = 0; ((i < count) && (i < z_grp_size)); i++) {
z_grp[i].id = n_grp[i].id;
- z_grp[i].weight = n_grp[i].weight;
+ z_grp[i].weight = n_grp[i].weight + 1;
}
return count;
}