diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2023-07-26 17:30:07 -0300 | 
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2023-09-04 15:38:03 -0300 | 
| commit | 6374aeab80c8590db2c7bbe21936d202aae5a2c0 (patch) | |
| tree | ee59e50f87231bf6db28a80f470d022297d5fee8 /zebra/rt_netlink.c | |
| parent | ff542b22d219107bede01c74b426ddda87c7a31d (diff) | |
zebra: support route replace semantics in FPM
Set `NLM_F_REPLACE` instead of adding and removing the same route for an
update.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'zebra/rt_netlink.c')
| -rw-r--r-- | zebra/rt_netlink.c | 15 | 
1 files changed, 8 insertions, 7 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 2318cd6374..12f8d89de0 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2060,10 +2060,10 @@ static int netlink_route_nexthop_encap(struct nlmsghdr *n, size_t nlen,   * Returns -1 on failure, 0 when the msg doesn't fit entirely in the buffer   * otherwise the number of bytes written to buf.   */ -ssize_t netlink_route_multipath_msg_encode(int cmd, -					   struct zebra_dplane_ctx *ctx, +ssize_t netlink_route_multipath_msg_encode(int cmd, struct zebra_dplane_ctx *ctx,  					   uint8_t *data, size_t datalen, -					   bool fpm, bool force_nhg) +					   bool fpm, bool force_nhg, +					   bool force_rr)  {  	int bytelen;  	struct nexthop *nexthop = NULL; @@ -2097,8 +2097,9 @@ ssize_t netlink_route_multipath_msg_encode(int cmd,  	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));  	req->n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST; -	if ((cmd == RTM_NEWROUTE) && -	    ((p->family == AF_INET) || v6_rr_semantics)) +	if (((cmd == RTM_NEWROUTE) && +	     ((p->family == AF_INET) || v6_rr_semantics)) || +	    force_rr)  		req->n.nlmsg_flags |= NLM_F_REPLACE;  	req->n.nlmsg_type = cmd; @@ -2953,14 +2954,14 @@ static ssize_t netlink_newroute_msg_encoder(struct zebra_dplane_ctx *ctx,  					    void *buf, size_t buflen)  {  	return netlink_route_multipath_msg_encode(RTM_NEWROUTE, ctx, buf, -						  buflen, false, false); +						  buflen, false, false, false);  }  static ssize_t netlink_delroute_msg_encoder(struct zebra_dplane_ctx *ctx,  					    void *buf, size_t buflen)  {  	return netlink_route_multipath_msg_encode(RTM_DELROUTE, ctx, buf, -						  buflen, false, false); +						  buflen, false, false, false);  }  enum netlink_msg_status  | 
