summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Worley <sworley@nvidia.com>2020-12-17 16:16:26 -0500
committerStephen Worley <sworley@nvidia.com>2020-12-18 11:53:18 -0500
commite36ea40d3bf0bec2b550bcedf75a266bf6be605f (patch)
tree317d28beae23948b467c3c680d7c4c1ef8252126
parent67765a232dc6d86b3acbd3f6e4ba87cea42cca48 (diff)
zebra: derive rule family from src->dst->ipv4
Derive the rule family from src if available, otherwise dst if available, otherwise assume ipv4. We only support ipv4/ipv6 currently so it we cant tell from the src/dst it must be ipv4 and likely a dsfield match. Signed-off-by: Stephen Worley <sworley@nvidia.com>
-rw-r--r--zebra/rule_netlink.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c
index a63504992e..08a675ef3a 100644
--- a/zebra/rule_netlink.c
+++ b/zebra/rule_netlink.c
@@ -79,7 +79,15 @@ netlink_rule_msg_encode(int cmd, const struct zebra_dplane_ctx *ctx,
if (buflen < sizeof(*req))
return 0;
memset(req, 0, sizeof(*req));
- family = PREFIX_FAMILY(src_ip);
+
+ /* Assume ipv4 if no src/dst set, we only support ipv4/ipv6 */
+ if (PREFIX_FAMILY(src_ip))
+ family = PREFIX_FAMILY(src_ip);
+ else if (PREFIX_FAMILY(dst_ip))
+ family = PREFIX_FAMILY(dst_ip);
+ else
+ family = AF_INET;
+
bytelen = (family == AF_INET ? 4 : 16);
req->n.nlmsg_type = cmd;