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.c76
1 files changed, 27 insertions, 49 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 5edcf9bb8a..43e44cad16 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1440,6 +1440,7 @@ static void _netlink_mpls_debug(int cmd, uint32_t label, const char *routedesc)
static int netlink_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla,
int llalen, ns_id_t ns_id)
{
+ uint8_t protocol = RTPROT_ZEBRA;
struct {
struct nlmsghdr n;
struct ndmsg ndm;
@@ -1460,6 +1461,8 @@ static int netlink_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla,
req.ndm.ndm_ifindex = ifindex;
req.ndm.ndm_type = RTN_UNICAST;
+ addattr_l(&req.n, sizeof(req),
+ NDA_PROTOCOL, &protocol, sizeof(protocol));
addattr_l(&req.n, sizeof(req), NDA_DST, &addr, 4);
addattr_l(&req.n, sizeof(req), NDA_LLADDR, lla, llalen);
@@ -1930,6 +1933,7 @@ int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
static int netlink_vxlan_flood_update_ctx(const struct zebra_dplane_ctx *ctx,
int cmd)
{
+ uint8_t protocol = RTPROT_ZEBRA;
struct {
struct nlmsghdr n;
struct ndmsg ndm;
@@ -1950,6 +1954,8 @@ static int netlink_vxlan_flood_update_ctx(const struct zebra_dplane_ctx *ctx,
req.ndm.ndm_flags |= NTF_SELF; // Handle by "self", not "master"
+ addattr_l(&req.n, sizeof(req),
+ NDA_PROTOCOL, &protocol, sizeof(protocol));
addattr_l(&req.n, sizeof(req), NDA_LLADDR, &dst_mac, 6);
req.ndm.ndm_ifindex = dplane_ctx_get_ifindex(ctx);
@@ -2297,6 +2303,7 @@ int netlink_macfdb_read_specific_mac(struct zebra_ns *zns,
static enum zebra_dplane_result
netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx)
{
+ uint8_t protocol = RTPROT_ZEBRA;
struct {
struct nlmsghdr n;
struct ndmsg ndm;
@@ -2304,13 +2311,7 @@ netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx)
} req;
int ret;
int dst_alen;
- struct zebra_if *zif;
- struct interface *br_if;
- struct zebra_if *br_zif;
int vid_present = 0;
- char vid_buf[20];
- struct zebra_ns *zns;
- struct interface *ifp;
int cmd;
struct in_addr vtep_ip;
vlanid_t vid;
@@ -2320,42 +2321,6 @@ netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx)
else
cmd = RTM_DELNEIGH;
- /* Locate zebra ns and interface objects from context data */
- zns = zebra_ns_lookup(dplane_ctx_get_ns(ctx)->ns_id);
- if (zns == NULL) {
- /* Nothing to be done */
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("MAC %s on IF %s(%u) - zebra ns unknown",
- (cmd == RTM_NEWNEIGH) ? "add" : "del",
- dplane_ctx_get_ifname(ctx),
- dplane_ctx_get_ifindex(ctx));
-
- return ZEBRA_DPLANE_REQUEST_FAILURE;
- }
-
- ifp = if_lookup_by_index_per_ns(zns, dplane_ctx_get_ifindex(ctx));
- if (ifp == NULL) {
- /* Nothing to be done */
- /* Nothing to be done */
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("MAC %s on IF %s(%u) - interface unknown",
- (cmd == RTM_NEWNEIGH) ? "add" : "del",
- dplane_ctx_get_ifname(ctx),
- dplane_ctx_get_ifindex(ctx));
- return ZEBRA_DPLANE_REQUEST_FAILURE;
- }
-
- vid = dplane_ctx_mac_get_vlan(ctx);
-
- zif = ifp->info;
- if ((br_if = zif->brslave_info.br_if) == NULL) {
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("MAC %s on IF %s(%u) - no mapping to bridge",
- (cmd == RTM_NEWNEIGH) ? "add" : "del",
- ifp->name, ifp->ifindex);
- return ZEBRA_DPLANE_REQUEST_FAILURE;
- }
-
memset(&req, 0, sizeof(req));
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg));
@@ -2372,26 +2337,35 @@ netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx)
else
req.ndm.ndm_flags |= NTF_EXT_LEARNED;
+ addattr_l(&req.n, sizeof(req),
+ NDA_PROTOCOL, &protocol, sizeof(protocol));
addattr_l(&req.n, sizeof(req), NDA_LLADDR,
dplane_ctx_mac_get_addr(ctx), 6);
- req.ndm.ndm_ifindex = ifp->ifindex;
+ req.ndm.ndm_ifindex = dplane_ctx_get_ifindex(ctx);
dst_alen = 4; // TODO: hardcoded
vtep_ip = *(dplane_ctx_mac_get_vtep_ip(ctx));
addattr_l(&req.n, sizeof(req), NDA_DST, &vtep_ip, dst_alen);
- br_zif = (struct zebra_if *)br_if->info;
- if (IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(br_zif) && vid > 0) {
+ vid = dplane_ctx_mac_get_vlan(ctx);
+
+ if (vid > 0) {
addattr16(&req.n, sizeof(req), NDA_VLAN, vid);
vid_present = 1;
- sprintf(vid_buf, " VLAN %u", vid);
}
- addattr32(&req.n, sizeof(req), NDA_MASTER, br_if->ifindex);
+ addattr32(&req.n, sizeof(req), NDA_MASTER,
+ dplane_ctx_mac_get_br_ifindex(ctx));
if (IS_ZEBRA_DEBUG_KERNEL) {
char ipbuf[PREFIX_STRLEN];
char buf[ETHER_ADDR_STRLEN];
char dst_buf[PREFIX_STRLEN + 10];
+ char vid_buf[20];
+
+ if (vid_present)
+ snprintf(vid_buf, sizeof(vid_buf), " VLAN %u", vid);
+ else
+ vid_buf[0] = '\0';
inet_ntop(AF_INET, &vtep_ip, ipbuf, sizeof(ipbuf));
snprintf(dst_buf, sizeof(dst_buf), " dst %s", ipbuf);
@@ -2399,8 +2373,9 @@ netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx)
zlog_debug("Tx %s family %s IF %s(%u)%s %sMAC %s%s",
nl_msg_type_to_str(cmd),
- nl_family_to_str(req.ndm.ndm_family), ifp->name,
- ifp->ifindex, vid_present ? vid_buf : "",
+ nl_family_to_str(req.ndm.ndm_family),
+ dplane_ctx_get_ifname(ctx),
+ dplane_ctx_get_ifindex(ctx), vid_buf,
dplane_ctx_mac_is_sticky(ctx) ? "sticky " : "",
buf, dst_buf);
}
@@ -2782,6 +2757,7 @@ int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id)
static int netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx,
int cmd)
{
+ uint8_t protocol = RTPROT_ZEBRA;
struct {
struct nlmsghdr n;
struct ndmsg ndm;
@@ -2816,6 +2792,8 @@ static int netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx,
req.ndm.ndm_type = RTN_UNICAST;
req.ndm.ndm_flags = flags;
+ addattr_l(&req.n, sizeof(req),
+ NDA_PROTOCOL, &protocol, sizeof(protocol));
ipa_len = IS_IPADDR_V4(ip) ? IPV4_MAX_BYTELEN : IPV6_MAX_BYTELEN;
addattr_l(&req.n, sizeof(req), NDA_DST, &ip->ip.addr, ipa_len);
if (mac)