]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Move fpm check to inside of netlink_route_nexthop_encap
authorDonald Sharp <sharpd@nvidia.com>
Wed, 8 May 2024 16:48:12 +0000 (12:48 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 9 May 2024 15:52:51 +0000 (11:52 -0400)
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/rt_netlink.c

index 745f6497fb2bba83c79cb47e92ce9f1feba1a730..9ac4bb9bf8bb37459722336b37d3d1136ef456f7 100644 (file)
@@ -1895,11 +1895,14 @@ static inline bool _netlink_set_tag(struct nlmsghdr *n, unsigned int maxlen,
  * The function returns true if the attribute could be added
  * to the message, otherwise false is returned.
  */
-static int netlink_route_nexthop_encap(struct nlmsghdr *n, size_t nlen,
-                                      struct nexthop *nh)
+static int netlink_route_nexthop_encap(bool fpm, struct nlmsghdr *n,
+                                      size_t nlen, struct nexthop *nh)
 {
        struct rtattr *nest;
 
+       if (!fpm)
+               return true;
+
        switch (nh->nh_encap_type) {
        case NET_VXLAN:
                if (!nl_attr_put16(n, nlen, RTA_ENCAP_TYPE, nh->nh_encap_type))
@@ -2430,12 +2433,10 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, struct zebra_dplane_ctx *ctx
                                 * Add encapsulation information when
                                 * installing via FPM.
                                 */
-                               if (fpm) {
-                                       if (!netlink_route_nexthop_encap(&req->n,
-                                                                        datalen,
-                                                                        nexthop))
-                                               return 0;
-                               }
+                               if (!netlink_route_nexthop_encap(fpm, &req->n,
+                                                                datalen,
+                                                                nexthop))
+                                       return 0;
 
                                nexthop_num++;
                                break;
@@ -2490,11 +2491,10 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, struct zebra_dplane_ctx *ctx
                                 * Add encapsulation information when installing via
                                 * FPM.
                                 */
-                               if (fpm) {
-                                       if (!netlink_route_nexthop_encap(
-                                                   &req->n, datalen, nexthop))
-                                               return 0;
-                               }
+                               if (!netlink_route_nexthop_encap(fpm, &req->n,
+                                                                datalen,
+                                                                nexthop))
+                                       return 0;
 
                                if (!setsrc && src1) {
                                        if (p->family == AF_INET)