zebra: Move fpm check to inside of netlink_route_nexthop_encap

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-05-08 12:48:12 -04:00
parent ba5a3538e8
commit 569f9e4394

View 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 * The function returns true if the attribute could be added
* to the message, otherwise false is returned. * to the message, otherwise false is returned.
*/ */
static int netlink_route_nexthop_encap(struct nlmsghdr *n, size_t nlen, static int netlink_route_nexthop_encap(bool fpm, struct nlmsghdr *n,
struct nexthop *nh) size_t nlen, struct nexthop *nh)
{ {
struct rtattr *nest; struct rtattr *nest;
if (!fpm)
return true;
switch (nh->nh_encap_type) { switch (nh->nh_encap_type) {
case NET_VXLAN: case NET_VXLAN:
if (!nl_attr_put16(n, nlen, RTA_ENCAP_TYPE, nh->nh_encap_type)) 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 * Add encapsulation information when
* installing via FPM. * installing via FPM.
*/ */
if (fpm) { if (!netlink_route_nexthop_encap(fpm, &req->n,
if (!netlink_route_nexthop_encap(&req->n, datalen,
datalen, nexthop))
nexthop)) return 0;
return 0;
}
nexthop_num++; nexthop_num++;
break; 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 * Add encapsulation information when installing via
* FPM. * FPM.
*/ */
if (fpm) { if (!netlink_route_nexthop_encap(fpm, &req->n,
if (!netlink_route_nexthop_encap( datalen,
&req->n, datalen, nexthop)) nexthop))
return 0; return 0;
}
if (!setsrc && src1) { if (!setsrc && src1) {
if (p->family == AF_INET) if (p->family == AF_INET)