Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evpn-mh: changes for programming synced neighs as static in the dataplane #7116

Merged
merged 2 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/linux/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum {
NDA_PROTOCOL, /* Originator of entry */
NDA_NH_ID,
NDA_NOTIFY,
NDA_EXT_FLAGS,
__NDA_MAX
};

Expand All @@ -49,6 +50,10 @@ enum {
#define NTF_STICKY 0x40
#define NTF_ROUTER 0x80

/* Neighbor Cache Entry extended flags, part of NDA_EXT_FLAGS attribute */
#define NTF_E_WEAK_OVERRIDE_STATE 0x01
#define NTF_E_MH_PEER_SYNC 0x02

/*
* Neighbor Cache Entry States.
*/
Expand Down
77 changes: 53 additions & 24 deletions zebra/rt_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2680,9 +2680,9 @@ int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
static ssize_t netlink_neigh_update_msg_encode(
const struct zebra_dplane_ctx *ctx, int cmd, const struct ethaddr *mac,
const struct ipaddr *ip, bool replace_obj, uint8_t family, uint8_t type,
uint8_t flags, uint16_t state, uint32_t nhg_id,
bool nfy, uint8_t nfy_flags,
void *data, size_t datalen)
uint8_t flags, uint16_t state, uint32_t nhg_id, bool nfy,
uint8_t nfy_flags, bool ext, uint32_t ext_flags, void *data,
size_t datalen)
{
uint8_t protocol = RTPROT_ZEBRA;
struct {
Expand Down Expand Up @@ -2731,6 +2731,12 @@ static ssize_t netlink_neigh_update_msg_encode(
return 0;
}

if (ext) {
if (!nl_attr_put(&req->n, datalen, NDA_EXT_FLAGS, &ext_flags,
sizeof(ext_flags)))
return 0;
}

ipa_len = IS_IPADDR_V4(ip) ? IPV4_MAX_BYTELEN : IPV6_MAX_BYTELEN;
if (!nl_attr_put(&req->n, datalen, NDA_DST, &ip->ip.addr, ipa_len))
return 0;
Expand Down Expand Up @@ -2764,7 +2770,8 @@ netlink_vxlan_flood_update_ctx(const struct zebra_dplane_ctx *ctx, int cmd,
return netlink_neigh_update_msg_encode(
ctx, cmd, &dst_mac, dplane_ctx_neigh_get_ipaddr(ctx), false,
PF_BRIDGE, 0, NTF_SELF, (NUD_NOARP | NUD_PERMANENT), 0 /*nhg*/,
false /*nfy*/, 0 /*nfy_flags*/, buf, buflen);
false /*nfy*/, 0 /*nfy_flags*/, false /*ext*/, 0 /*ext_flags*/,
buf, buflen);
}

#ifndef NDA_RTA
Expand Down Expand Up @@ -3174,30 +3181,26 @@ ssize_t netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx, void *data,
else
vid_buf[0] = '\0';

zlog_debug("Tx %s family %s IF %s(%u)%s %sMAC %s dst %s nhg %u%s%s%s%s%s",
nl_msg_type_to_str(cmd), nl_family_to_str(AF_BRIDGE),
dplane_ctx_get_ifname(ctx),
dplane_ctx_get_ifindex(ctx), vid_buf,
dplane_ctx_mac_is_sticky(ctx) ? "sticky " : "",
prefix_mac2str(mac, buf, sizeof(buf)),
ipaddr2str(&vtep_ip, ipbuf, sizeof(ipbuf)),
nhg_id,
(update_flags &
DPLANE_MAC_REMOTE) ? " rem" : "",
(update_flags &
DPLANE_MAC_WAS_STATIC) ? " clr_sync" : "",
(update_flags &
DPLANE_MAC_SET_STATIC) ? " static" : "",
(update_flags &
DPLANE_MAC_SET_INACTIVE) ? " inactive" : "",
(nfy &
DPLANE_MAC_SET_INACTIVE) ? " nfy" : "");
zlog_debug(
"Tx %s family %s IF %s(%u)%s %sMAC %s dst %s nhg %u%s%s%s%s%s",
nl_msg_type_to_str(cmd), nl_family_to_str(AF_BRIDGE),
dplane_ctx_get_ifname(ctx), dplane_ctx_get_ifindex(ctx),
vid_buf, dplane_ctx_mac_is_sticky(ctx) ? "sticky " : "",
prefix_mac2str(mac, buf, sizeof(buf)),
ipaddr2str(&vtep_ip, ipbuf, sizeof(ipbuf)), nhg_id,
(update_flags & DPLANE_MAC_REMOTE) ? " rem" : "",
(update_flags & DPLANE_MAC_WAS_STATIC) ? " clr_sync"
: "",
(update_flags & DPLANE_MAC_SET_STATIC) ? " static" : "",
(update_flags & DPLANE_MAC_SET_INACTIVE) ? " inactive"
: "",
nfy ? " nfy" : "");
}

total = netlink_neigh_update_msg_encode(
ctx, cmd, dplane_ctx_mac_get_addr(ctx), &vtep_ip, true,
AF_BRIDGE, 0, flags, state, nhg_id, nfy, nfy_flags,
data, datalen);
false /*ext*/, 0 /*ext_flags*/, data, datalen);

return total;
}
Expand Down Expand Up @@ -3598,17 +3601,42 @@ static ssize_t netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx,
uint8_t flags;
uint16_t state;
uint8_t family;
uint32_t update_flags;
uint32_t ext_flags = 0;
bool ext = false;

ip = dplane_ctx_neigh_get_ipaddr(ctx);
mac = dplane_ctx_neigh_get_mac(ctx);
if (is_zero_mac(mac))
mac = NULL;

update_flags = dplane_ctx_neigh_get_update_flags(ctx);
flags = neigh_flags_to_netlink(dplane_ctx_neigh_get_flags(ctx));
state = neigh_state_to_netlink(dplane_ctx_neigh_get_state(ctx));

family = IS_IPADDR_V4(ip) ? AF_INET : AF_INET6;

if (update_flags & DPLANE_NEIGH_REMOTE) {
flags |= NTF_EXT_LEARNED;
/* if it was static-local previously we need to clear the
* ext flags on replace with remote
*/
if (update_flags & DPLANE_NEIGH_WAS_STATIC)
ext = true;
} else {
ext = true;
/* local neigh */
if (update_flags & DPLANE_NEIGH_SET_STATIC)
ext_flags |= NTF_E_MH_PEER_SYNC;

/* the ndm_state set for local entries can be REACHABLE or
* STALE. if the dataplane has already establish reachability
* (in the meantime) FRR must not over-write it with STALE.
* this accidental race/over-write is avoided by using the
* WEAK_OVERRIDE_STATE
*/
ext_flags |= NTF_E_WEAK_OVERRIDE_STATE;
}
if (IS_ZEBRA_DEBUG_KERNEL) {
char buf[INET6_ADDRSTRLEN];
char buf2[ETHER_ADDR_STRLEN];
Expand All @@ -3624,7 +3652,8 @@ static ssize_t netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx,

return netlink_neigh_update_msg_encode(
ctx, cmd, mac, ip, true, family, RTN_UNICAST, flags, state,
0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/, buf, buflen);
0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/, ext, ext_flags, buf,
buflen);
}

static ssize_t netlink_neigh_msg_encoder(struct zebra_dplane_ctx *ctx,
Expand Down