summaryrefslogtreecommitdiffstats
path: root/zebra/zapi_msg.c
diff options
context:
space:
mode:
authorG. Paul Ziemba <paulz@labn.net>2023-07-31 06:33:10 +0200
committerG. Paul Ziemba <paulz@labn.net>2023-08-09 21:11:35 +0200
commit887367a01c0e978e992935ae93f3df4e3c1bd86c (patch)
tree533826535f9359febf6b935fb6ee44b63121c63a /zebra/zapi_msg.c
parentpbrd: add explicit 'family' field for rules (diff)
downloadfrr-887367a01c0e978e992935ae93f3df4e3c1bd86c.tar.xz
frr-887367a01c0e978e992935ae93f3df4e3c1bd86c.zip
pbrd: use flags to indicate active fields
Before now, PBRD used non-zero values to imply that a rule's match or action field was active. This approach was getting cumbersome for fields where 0 is a valid active value and various field-specific magic values had to be used. This commit changes PBRD to use a flag bit per field to indicate that the field is active. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
Diffstat (limited to '')
-rw-r--r--zebra/zapi_msg.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index e9c243217..f6afb006b 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -3188,10 +3188,32 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS)
strlcpy(zpr.ifname, zpr.rule.ifname, sizeof(zpr.ifname));
+ if ((zpr.rule.family != AF_INET) &&
+ (zpr.rule.family != AF_INET6)) {
+ zlog_warn("Unsupported PBR source IP family: %s (%hhu)",
+ family2str(zpr.rule.family), zpr.rule.family);
+ return;
+ }
+
+ /*
+ * Fixup filter src/dst IP addresses if they are unset
+ * because the netlink code currently obtains address family
+ * from them. Address family is used to specify which
+ * kernel database to use when adding/deleting rule.
+ *
+ * TBD: propagate zpr.rule.family into dataplane and
+ * netlink code so they can stop using filter src/dst addrs.
+ */
+ if (!CHECK_FLAG(zpr.rule.filter.filter_bm, PBR_FILTER_SRC_IP))
+ zpr.rule.filter.src_ip.family = zpr.rule.family;
+ if (!CHECK_FLAG(zpr.rule.filter.filter_bm, PBR_FILTER_DST_IP))
+ zpr.rule.filter.dst_ip.family = zpr.rule.family;
+
+ /* TBD delete below block when netlink code gets family from zpr.rule.family */
if (!(zpr.rule.filter.src_ip.family == AF_INET
|| zpr.rule.filter.src_ip.family == AF_INET6)) {
zlog_warn(
- "Unsupported PBR source IP family: %s (%hhu)",
+ "Unsupported PBR source IP family: %s (%u)",
family2str(zpr.rule.filter.src_ip.family),
zpr.rule.filter.src_ip.family);
return;
@@ -3199,11 +3221,12 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS)
if (!(zpr.rule.filter.dst_ip.family == AF_INET
|| zpr.rule.filter.dst_ip.family == AF_INET6)) {
zlog_warn(
- "Unsupported PBR destination IP family: %s (%hhu)",
+ "Unsupported PBR destination IP family: %s (%u)",
family2str(zpr.rule.filter.dst_ip.family),
zpr.rule.filter.dst_ip.family);
return;
}
+ /* TBD delete above block when netlink code gets family from zpr.rule.family */
zpr.vrf_id = zvrf->vrf->vrf_id;