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
* 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)