diff options
| author | Sharath Ramamurthy <sramamurthy@nvidia.com> | 2021-07-27 13:22:11 +0530 | 
|---|---|---|
| committer | Stephen Worley <sworley@nvidia.com> | 2023-02-13 18:12:04 -0500 | 
| commit | b95ce8fadbceea40639224d59bfcc0a2679f5604 (patch) | |
| tree | 77baf12b6777643344377e0798bc1d461c8bb307 | |
| parent | 784d88aa14c115411ed21f6ac518ab1a8f9d27b7 (diff) | |
zebra: single vxlan device dataplace vni update changes
dplane_mac_info and dplane_neigh_info is modified to be vni aware.
dplane_rem_mac_add/del dplane_mac_init is modified to be vni aware.
During dplane context update (mac and neigh), we use the vni information
and if set, corresponding netlink attribute NDA_SRC_VNI is set and passed to the
dplane.
Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
| -rw-r--r-- | zebra/dplane_fpm_nl.c | 6 | ||||
| -rw-r--r-- | zebra/rt_netlink.c | 15 | ||||
| -rw-r--r-- | zebra/zebra_dplane.c | 90 | ||||
| -rw-r--r-- | zebra/zebra_dplane.h | 36 | ||||
| -rw-r--r-- | zebra/zebra_evpn_mac.c | 5 | ||||
| -rw-r--r-- | zebra/zebra_vxlan.c | 8 | 
6 files changed, 87 insertions, 73 deletions
diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index 8fb230ffa7..6a0f02bab4 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -1208,9 +1208,9 @@ static void fpm_enqueue_rmac_table(struct hash_bucket *bucket, void *arg)  	dplane_ctx_reset(fra->ctx);  	dplane_ctx_set_op(fra->ctx, DPLANE_OP_MAC_INSTALL);  	dplane_mac_init(fra->ctx, fra->zl3vni->vxlan_if, -			zif->brslave_info.br_if, vid, -			&zrmac->macaddr, zrmac->fwd_info.r_vtep_ip, sticky, -			0 /*nhg*/, 0 /*update_flags*/); +			zif->brslave_info.br_if, vid, &zrmac->macaddr, vni->vni, +			zrmac->fwd_info.r_vtep_ip, sticky, 0 /*nhg*/, +			0 /*update_flags*/);  	if (fpm_nl_enqueue(fra->fnc, fra->ctx) == -1) {  		thread_add_timer(zrouter.master, fpm_rmac_send,  				 fra->fnc, 1, &fra->fnc->t_rmacwalk); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 21222408b7..6fbe350435 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -3416,17 +3416,32 @@ static ssize_t netlink_neigh_update_msg_encode(  	if (op == DPLANE_OP_MAC_INSTALL || op == DPLANE_OP_MAC_DELETE) {  		vlanid_t vid = dplane_ctx_mac_get_vlan(ctx); +		vni_t vni = dplane_ctx_mac_get_vni(ctx);  		if (vid > 0) {  			if (!nl_attr_put16(&req->n, datalen, NDA_VLAN, vid))  				return 0;  		} +		if (vni > 0) { +			if (!nl_attr_put32(&req->n, datalen, NDA_SRC_VNI, vni)) +				return 0; +		} +  		if (!nl_attr_put32(&req->n, datalen, NDA_MASTER,  				   dplane_ctx_mac_get_br_ifindex(ctx)))  			return 0;  	} +	if (op == DPLANE_OP_VTEP_ADD || op == DPLANE_OP_VTEP_DELETE) { +		vni_t vni = dplane_ctx_neigh_get_vni(ctx); + +		if (vni > 0) { +			if (!nl_attr_put32(&req->n, datalen, NDA_SRC_VNI, vni)) +				return 0; +		} +	} +  	return NLMSG_ALIGN(req->n.nlmsg_len);  } diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index ef4cef65ca..1f32351d4c 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -222,6 +222,7 @@ struct dplane_mac_info {  	vlanid_t vid;  	ifindex_t br_ifindex;  	struct ethaddr mac; +	vni_t vni;  	struct in_addr vtep_ip;  	bool is_sticky;  	uint32_t nhg_id; @@ -237,6 +238,7 @@ struct dplane_neigh_info {  		struct ethaddr mac;  		struct ipaddr ip_addr;  	} link; +	vni_t vni;  	uint32_t flags;  	uint16_t state;  	uint32_t update_flags; @@ -628,12 +630,11 @@ static enum zebra_dplane_result pw_update_internal(struct zebra_pw *pw,  static enum zebra_dplane_result intf_addr_update_internal(  	const struct interface *ifp, const struct connected *ifc,  	enum dplane_op_e op); -static enum zebra_dplane_result mac_update_common( -	enum dplane_op_e op, const struct interface *ifp, -	const struct interface *br_ifp, -	vlanid_t vid, const struct ethaddr *mac, -	struct in_addr vtep_ip,	bool sticky, uint32_t nhg_id, -	uint32_t update_flags); +static enum zebra_dplane_result +mac_update_common(enum dplane_op_e op, const struct interface *ifp, +		  const struct interface *br_ifp, vlanid_t vid, +		  const struct ethaddr *mac, vni_t vni, struct in_addr vtep_ip, +		  bool sticky, uint32_t nhg_id, uint32_t update_flags);  static enum zebra_dplane_result  neigh_update_internal(enum dplane_op_e op, const struct interface *ifp,  		      const void *link, int link_family, @@ -2229,6 +2230,12 @@ const struct ethaddr *dplane_ctx_mac_get_addr(  	return &(ctx->u.macinfo.mac);  } +vni_t dplane_ctx_mac_get_vni(const struct zebra_dplane_ctx *ctx) +{ +	DPLANE_CTX_VALID(ctx); +	return ctx->u.macinfo.vni; +} +  const struct in_addr *dplane_ctx_mac_get_vtep_ip(  	const struct zebra_dplane_ctx *ctx)  { @@ -2264,6 +2271,12 @@ const struct ethaddr *dplane_ctx_neigh_get_mac(  	return &(ctx->u.neigh.link.mac);  } +vni_t dplane_ctx_neigh_get_vni(const struct zebra_dplane_ctx *ctx) +{ +	DPLANE_CTX_VALID(ctx); +	return ctx->u.neigh.vni; +} +  uint32_t dplane_ctx_neigh_get_flags(const struct zebra_dplane_ctx *ctx)  {  	DPLANE_CTX_VALID(ctx); @@ -4649,14 +4662,11 @@ enum zebra_dplane_result dplane_intf_delete(const struct interface *ifp)  /*   * Enqueue vxlan/evpn mac add (or update).   */ -enum zebra_dplane_result dplane_rem_mac_add(const struct interface *ifp, -					const struct interface *bridge_ifp, -					vlanid_t vid, -					const struct ethaddr *mac, -					struct in_addr vtep_ip, -					bool sticky, -					uint32_t nhg_id, -					bool was_static) +enum zebra_dplane_result +dplane_rem_mac_add(const struct interface *ifp, +		   const struct interface *bridge_ifp, vlanid_t vid, +		   const struct ethaddr *mac, vni_t vni, struct in_addr vtep_ip, +		   bool sticky, uint32_t nhg_id, bool was_static)  {  	enum zebra_dplane_result result;  	uint32_t update_flags = 0; @@ -4666,8 +4676,9 @@ enum zebra_dplane_result dplane_rem_mac_add(const struct interface *ifp,  		update_flags |= DPLANE_MAC_WAS_STATIC;  	/* Use common helper api */ -	result = mac_update_common(DPLANE_OP_MAC_INSTALL, ifp, bridge_ifp, -				   vid, mac, vtep_ip, sticky, nhg_id, update_flags); +	result = mac_update_common(DPLANE_OP_MAC_INSTALL, ifp, bridge_ifp, vid, +				   mac, vni, vtep_ip, sticky, nhg_id, +				   update_flags);  	return result;  } @@ -4675,10 +4686,10 @@ enum zebra_dplane_result dplane_rem_mac_add(const struct interface *ifp,   * Enqueue vxlan/evpn mac delete.   */  enum zebra_dplane_result dplane_rem_mac_del(const struct interface *ifp, -					const struct interface *bridge_ifp, -					vlanid_t vid, -					const struct ethaddr *mac, -					struct in_addr vtep_ip) +					    const struct interface *bridge_ifp, +					    vlanid_t vid, +					    const struct ethaddr *mac, +					    vni_t vni, struct in_addr vtep_ip)  {  	enum zebra_dplane_result result;  	uint32_t update_flags = 0; @@ -4686,8 +4697,8 @@ enum zebra_dplane_result dplane_rem_mac_del(const struct interface *ifp,  	update_flags |= DPLANE_MAC_REMOTE;  	/* Use common helper api */ -	result = mac_update_common(DPLANE_OP_MAC_DELETE, ifp, bridge_ifp, -				   vid, mac, vtep_ip, false, 0, update_flags); +	result = mac_update_common(DPLANE_OP_MAC_DELETE, ifp, bridge_ifp, vid, +				   mac, vni, vtep_ip, false, 0, update_flags);  	return result;  } @@ -4746,9 +4757,8 @@ enum zebra_dplane_result dplane_local_mac_add(const struct interface *ifp,  	vtep_ip.s_addr = 0;  	/* Use common helper api */ -	result = mac_update_common(DPLANE_OP_MAC_INSTALL, ifp, bridge_ifp, -				     vid, mac, vtep_ip, sticky, 0, -				     update_flags); +	result = mac_update_common(DPLANE_OP_MAC_INSTALL, ifp, bridge_ifp, vid, +				   mac, 0, vtep_ip, sticky, 0, update_flags);  	return result;  } @@ -4767,21 +4777,17 @@ dplane_local_mac_del(const struct interface *ifp,  	/* Use common helper api */  	result = mac_update_common(DPLANE_OP_MAC_DELETE, ifp, bridge_ifp, vid, -				   mac, vtep_ip, false, 0, 0); +				   mac, 0, vtep_ip, false, 0, 0);  	return result;  }  /*   * Public api to init an empty context - either newly-allocated or   * reset/cleared - for a MAC update.   */ -void dplane_mac_init(struct zebra_dplane_ctx *ctx, -		     const struct interface *ifp, -		     const struct interface *br_ifp, -		     vlanid_t vid, -		     const struct ethaddr *mac, -		     struct in_addr vtep_ip, -		     bool sticky, -		     uint32_t nhg_id, +void dplane_mac_init(struct zebra_dplane_ctx *ctx, const struct interface *ifp, +		     const struct interface *br_ifp, vlanid_t vid, +		     const struct ethaddr *mac, vni_t vni, +		     struct in_addr vtep_ip, bool sticky, uint32_t nhg_id,  		     uint32_t update_flags)  {  	struct zebra_ns *zns; @@ -4801,6 +4807,7 @@ void dplane_mac_init(struct zebra_dplane_ctx *ctx,  	ctx->u.macinfo.br_ifindex = br_ifp->ifindex;  	ctx->u.macinfo.vtep_ip = vtep_ip;  	ctx->u.macinfo.mac = *mac; +	ctx->u.macinfo.vni = vni;  	ctx->u.macinfo.vid = vid;  	ctx->u.macinfo.is_sticky = sticky;  	ctx->u.macinfo.nhg_id = nhg_id; @@ -4811,15 +4818,10 @@ void dplane_mac_init(struct zebra_dplane_ctx *ctx,   * Common helper api for MAC address/vxlan updates   */  static enum zebra_dplane_result -mac_update_common(enum dplane_op_e op, -		  const struct interface *ifp, -		  const struct interface *br_ifp, -		  vlanid_t vid, -		  const struct ethaddr *mac, -		  struct in_addr vtep_ip, -		  bool sticky, -		  uint32_t nhg_id, -		  uint32_t update_flags) +mac_update_common(enum dplane_op_e op, const struct interface *ifp, +		  const struct interface *br_ifp, vlanid_t vid, +		  const struct ethaddr *mac, vni_t vni, struct in_addr vtep_ip, +		  bool sticky, uint32_t nhg_id, uint32_t update_flags)  {  	enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;  	int ret; @@ -4833,7 +4835,7 @@ mac_update_common(enum dplane_op_e op,  	ctx->zd_op = op;  	/* Common init for the ctx */ -	dplane_mac_init(ctx, ifp, br_ifp, vid, mac, vtep_ip, sticky, +	dplane_mac_init(ctx, ifp, br_ifp, vid, mac, vni, vtep_ip, sticky,  			nhg_id, update_flags);  	/* Enqueue for processing on the dplane pthread */ diff --git a/zebra/zebra_dplane.h b/zebra/zebra_dplane.h index ae13243a16..0c84992051 100644 --- a/zebra/zebra_dplane.h +++ b/zebra/zebra_dplane.h @@ -568,6 +568,7 @@ uint32_t dplane_ctx_mac_get_update_flags(const struct zebra_dplane_ctx *ctx);  uint32_t dplane_ctx_mac_get_nhg_id(const struct zebra_dplane_ctx *ctx);  const struct ethaddr *dplane_ctx_mac_get_addr(  	const struct zebra_dplane_ctx *ctx); +vni_t dplane_ctx_mac_get_vni(const struct zebra_dplane_ctx *ctx);  const struct in_addr *dplane_ctx_mac_get_vtep_ip(  	const struct zebra_dplane_ctx *ctx);  ifindex_t dplane_ctx_mac_get_br_ifindex(const struct zebra_dplane_ctx *ctx); @@ -577,6 +578,7 @@ const struct ipaddr *dplane_ctx_neigh_get_ipaddr(  	const struct zebra_dplane_ctx *ctx);  const struct ethaddr *dplane_ctx_neigh_get_mac(  	const struct zebra_dplane_ctx *ctx); +vni_t dplane_ctx_neigh_get_vni(const struct zebra_dplane_ctx *ctx);  const struct ipaddr *  dplane_ctx_neigh_get_link_ip(const struct zebra_dplane_ctx *ctx);  uint32_t dplane_ctx_neigh_get_flags(const struct zebra_dplane_ctx *ctx); @@ -792,14 +794,11 @@ enum zebra_dplane_result dplane_neigh_ip_update(enum dplane_op_e op,  /*   * Enqueue evpn mac operations for the dataplane.   */ -enum zebra_dplane_result dplane_rem_mac_add(const struct interface *ifp, -					const struct interface *bridge_ifp, -					vlanid_t vid, -					const struct ethaddr *mac, -					struct in_addr vtep_ip, -					bool sticky, -					uint32_t nhg_id, -					bool was_static); +enum zebra_dplane_result +dplane_rem_mac_add(const struct interface *ifp, +		   const struct interface *bridge_ifp, vlanid_t vid, +		   const struct ethaddr *mac, vni_t vni, struct in_addr vtep_ip, +		   bool sticky, uint32_t nhg_id, bool was_static);  enum zebra_dplane_result dplane_local_mac_add(const struct interface *ifp,  					const struct interface *bridge_ifp, @@ -815,20 +814,17 @@ dplane_local_mac_del(const struct interface *ifp,  		     const struct ethaddr *mac);  enum zebra_dplane_result dplane_rem_mac_del(const struct interface *ifp, -					const struct interface *bridge_ifp, -					vlanid_t vid, -					const struct ethaddr *mac, -					struct in_addr vtep_ip); +					    const struct interface *bridge_ifp, +					    vlanid_t vid, +					    const struct ethaddr *mac, +					    vni_t vni, struct in_addr vtep_ip);  /* Helper api to init an empty or new context for a MAC update */ -void dplane_mac_init(struct zebra_dplane_ctx *ctx, -		     const struct interface *ifp, -		     const struct interface *br_ifp, -		     vlanid_t vid, -		     const struct ethaddr *mac, -		     struct in_addr vtep_ip, -		     bool sticky, -		     uint32_t nhg_id, uint32_t update_flags); +void dplane_mac_init(struct zebra_dplane_ctx *ctx, const struct interface *ifp, +		     const struct interface *br_ifp, vlanid_t vid, +		     const struct ethaddr *mac, vni_t vni, +		     struct in_addr vtep_ip, bool sticky, uint32_t nhg_id, +		     uint32_t update_flags);  /*   * Enqueue evpn neighbor updates for the dataplane. diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index 4b30a54488..4babbe97cd 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -242,7 +242,7 @@ int zebra_evpn_rem_mac_install(struct zebra_evpn *zevpn, struct zebra_mac *mac,  		vid = 0;  	res = dplane_rem_mac_add(zevpn->vxlan_if, br_ifp, vid, &mac->macaddr, -				 vtep_ip, sticky, nhg_id, was_static); +				 vni->vni, vtep_ip, sticky, nhg_id, was_static);  	if (res != ZEBRA_DPLANE_REQUEST_FAILURE)  		return 0;  	else @@ -296,7 +296,8 @@ int zebra_evpn_rem_mac_uninstall(struct zebra_evpn *zevpn,  	ifp = zevpn->vxlan_if;  	vtep_ip = mac->fwd_info.r_vtep_ip; -	res = dplane_rem_mac_del(ifp, br_ifp, vid, &mac->macaddr, vtep_ip); +	res = dplane_rem_mac_del(ifp, br_ifp, vid, &mac->macaddr, vni->vni, +				 vtep_ip);  	if (res != ZEBRA_DPLANE_REQUEST_FAILURE)  		return 0;  	else diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 0df43982e6..79f696c97d 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -1245,8 +1245,8 @@ static int zl3vni_rmac_install(struct zebra_l3vni *zl3vni,  	else  		vid = 0; -	res = dplane_rem_mac_add(zl3vni->vxlan_if, br_ifp, vid, -			     &zrmac->macaddr, zrmac->fwd_info.r_vtep_ip, 0, 0, +	res = dplane_rem_mac_add(zl3vni->vxlan_if, br_ifp, vid, &zrmac->macaddr, +				 vni->vni, zrmac->fwd_info.r_vtep_ip, 0, 0,  				 false /*was_static*/);  	if (res != ZEBRA_DPLANE_REQUEST_FAILURE)  		return 0; @@ -1294,8 +1294,8 @@ static int zl3vni_rmac_uninstall(struct zebra_l3vni *zl3vni,  	else  		vid = 0; -	res = dplane_rem_mac_del(zl3vni->vxlan_if, br_ifp, vid, -			     &zrmac->macaddr, zrmac->fwd_info.r_vtep_ip); +	res = dplane_rem_mac_del(zl3vni->vxlan_if, br_ifp, vid, &zrmac->macaddr, +				 vni->vni, zrmac->fwd_info.r_vtep_ip);  	if (res != ZEBRA_DPLANE_REQUEST_FAILURE)  		return 0;  	else  | 
