diff options
Diffstat (limited to 'zebra/rt_netlink.c')
| -rw-r--r-- | zebra/rt_netlink.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index c4af082e72..882babec81 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -93,7 +93,8 @@ static struct in_addr ipv4_ll; /* Helper to control use of kernel-level nexthop ids */ static bool kernel_nexthops_supported(void) { - return (supports_nh && zebra_nhg_kernel_nexthops_enabled()); + return (supports_nh && !vrf_is_backend_netns() + && zebra_nhg_kernel_nexthops_enabled()); } /* @@ -290,7 +291,7 @@ static inline int proto2zebra(int proto, int family, bool is_nexthop) /* Pending: create an efficient table_id (in a tree/hash) based lookup) */ -static vrf_id_t vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id) +vrf_id_t vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id) { struct vrf *vrf; struct zebra_vrf *zvrf; @@ -904,8 +905,8 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h, ifp = if_lookup_by_index(oif[count], vrf); char temp[256]; - sprintf(temp, "%s(%d) ", ifp ? ifp->name : "Unknown", - oif[count]); + snprintf(temp, sizeof(temp), "%s(%d) ", + ifp ? ifp->name : "Unknown", oif[count]); strlcat(oif_list, temp, sizeof(oif_list)); } zvrf = zebra_vrf_lookup_by_id(vrf); @@ -983,7 +984,7 @@ static int netlink_request_route(struct zebra_ns *zns, int family, int type) req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.rtm.rtm_family = family; - return netlink_request(&zns->netlink_cmd, &req.n); + return netlink_request(&zns->netlink_cmd, &req); } /* Routing table read function using netlink interface. Only called @@ -1087,7 +1088,8 @@ static int build_label_stack(struct mpls_label_stack *nh_label, sprintf(label_buf, "label %u", nh_label->label[i]); else { - sprintf(label_buf1, "/%u", nh_label->label[i]); + snprintf(label_buf1, sizeof(label_buf1), "/%u", + nh_label->label[i]); strlcat(label_buf, label_buf1, label_buf_size); } } @@ -2090,8 +2092,8 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx) nexthop_done: if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("%s: ID (%u): %pNHv vrf %s(%u) %s ", - __func__, id, nh, + zlog_debug("%s: ID (%u): %pNHv(%d) vrf %s(%u) %s ", + __func__, id, nh, nh->ifindex, vrf_id_to_name(nh->vrf_id), nh->vrf_id, label_buf); } @@ -2492,7 +2494,7 @@ static int netlink_request_nexthop(struct zebra_ns *zns, int family, int type) req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct nhmsg)); req.nhm.nh_family = family; - return netlink_request(&zns->netlink_cmd, &req.n); + return netlink_request(&zns->netlink_cmd, &req); } @@ -2686,7 +2688,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) if ((NDA_VLAN <= NDA_MAX) && tb[NDA_VLAN]) { vid_present = 1; vid = *(uint16_t *)RTA_DATA(tb[NDA_VLAN]); - sprintf(vid_buf, " VLAN %u", vid); + snprintf(vid_buf, sizeof(vid_buf), " VLAN %u", vid); } if (tb[NDA_DST]) { @@ -2694,7 +2696,8 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) dst_present = 1; memcpy(&vtep_ip.s_addr, RTA_DATA(tb[NDA_DST]), IPV4_MAX_BYTELEN); - sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip)); + snprintf(dst_buf, sizeof(dst_buf), " dst %s", + inet_ntoa(vtep_ip)); } if (IS_ZEBRA_DEBUG_KERNEL) @@ -2822,7 +2825,7 @@ static int netlink_request_macs(struct nlsock *netlink_cmd, int family, if (master_ifindex) addattr32(&req.n, sizeof(req), IFLA_MASTER, master_ifindex); - return netlink_request(netlink_cmd, &req.n); + return netlink_request(netlink_cmd, &req); } /* @@ -2925,7 +2928,7 @@ static int netlink_request_specific_mac_in_bridge(struct zebra_ns *zns, vrf_id_to_name(br_if->vrf_id), br_if->vrf_id, prefix_mac2str(mac, buf, sizeof(buf)), vid); - return netlink_request(&zns->netlink_cmd, &req.n); + return netlink_request(&zns->netlink_cmd, &req); } int netlink_macfdb_read_specific_mac(struct zebra_ns *zns, @@ -3225,7 +3228,7 @@ static int netlink_request_neigh(struct nlsock *netlink_cmd, int family, if (ifindex) addattr32(&req.n, sizeof(req), NDA_IFINDEX, ifindex); - return netlink_request(netlink_cmd, &req.n); + return netlink_request(netlink_cmd, &req); } /* @@ -3313,7 +3316,7 @@ static int netlink_request_specific_neigh_in_vlan(struct zebra_ns *zns, ipaddr2str(ip, buf, sizeof(buf)), req.n.nlmsg_flags); } - return netlink_request(&zns->netlink_cmd, &req.n); + return netlink_request(&zns->netlink_cmd, &req); } int netlink_neigh_read_specific_ip(struct ipaddr *ip, |
