]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/rule_netlink.c
isisd: implement the 'lsp-too-large' notification
[mirror_frr.git] / zebra / rule_netlink.c
index 310f0952faa3e4c11a3a64686718a7141294af59..7686a0ac32bc6d22a2bf8c1b013dce83ffbd86b9 100644 (file)
@@ -40,6 +40,7 @@
 #include "zebra/kernel_netlink.h"
 #include "zebra/rule_netlink.h"
 #include "zebra/zebra_pbr.h"
+#include "zebra/zebra_errors.h"
 
 /* definitions */
 
@@ -98,6 +99,12 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule)
                          &rule->rule.filter.dst_ip.u.prefix, bytelen);
        }
 
+       /* fwmark, if specified */
+       if (IS_RULE_FILTERING_ON_FWMARK(rule)) {
+               addattr32(&req.n, sizeof(req), FRA_FWMARK,
+                         rule->rule.filter.fwmark);
+       }
+
        /* Route table to use to forward, if filter criteria matches. */
        if (rule->rule.action.table < 256)
                req.frh.table = rule->rule.action.table;
@@ -136,27 +143,31 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule)
  * goes in the rule to denote relative ordering; it may or may not be the
  * same as the rule's user-defined sequence number.
  */
-void kernel_add_pbr_rule(struct zebra_pbr_rule *rule)
+enum zebra_dplane_result kernel_add_pbr_rule(struct zebra_pbr_rule *rule)
 {
        int ret = 0;
 
        ret = netlink_rule_update(RTM_NEWRULE, rule);
        kernel_pbr_rule_add_del_status(rule,
-                                      (!ret) ? SOUTHBOUND_INSTALL_SUCCESS
-                                             : SOUTHBOUND_INSTALL_FAILURE);
+                                      (!ret) ? ZEBRA_DPLANE_INSTALL_SUCCESS
+                                             : ZEBRA_DPLANE_INSTALL_FAILURE);
+
+       return ZEBRA_DPLANE_REQUEST_SUCCESS;
 }
 
 /*
  * Uninstall specified rule for a specific interface.
  */
-void kernel_del_pbr_rule(struct zebra_pbr_rule *rule)
+enum zebra_dplane_result kernel_del_pbr_rule(struct zebra_pbr_rule *rule)
 {
        int ret = 0;
 
        ret = netlink_rule_update(RTM_DELRULE, rule);
        kernel_pbr_rule_add_del_status(rule,
-                                      (!ret) ? SOUTHBOUND_DELETE_SUCCESS
-                                             : SOUTHBOUND_DELETE_FAILURE);
+                                      (!ret) ? ZEBRA_DPLANE_DELETE_SUCCESS
+                                             : ZEBRA_DPLANE_DELETE_FAILURE);
+
+       return ZEBRA_DPLANE_REQUEST_SUCCESS;
 }
 
 /*
@@ -166,8 +177,7 @@ void kernel_del_pbr_rule(struct zebra_pbr_rule *rule)
  * notification of interest. The expectation is that if this corresponds
  * to a PBR rule added by FRR, it will be readded.
  */
-int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
-                       ns_id_t ns_id, int startup)
+int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
 {
        struct zebra_ns *zns;
        struct fib_rule_hdr *frh;
@@ -187,12 +197,21 @@ int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
                return 0;
 
        len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct fib_rule_hdr));
-       if (len < 0)
+       if (len < 0) {
+               zlog_err("%s: Message received from netlink is of a broken size: %d %zu",
+                        __PRETTY_FUNCTION__, h->nlmsg_len,
+                        (size_t)NLMSG_LENGTH(sizeof(struct fib_rule_hdr)));
                return -1;
+       }
 
        frh = NLMSG_DATA(h);
-       if (frh->family != AF_INET && frh->family != AF_INET6)
+       if (frh->family != AF_INET && frh->family != AF_INET6) {
+               flog_warn(
+                       EC_ZEBRA_NETLINK_INVALID_AF,
+                       "Invalid address family: %u received from kernel rule change: %u",
+                       frh->family, h->nlmsg_type);
                return 0;
+       }
        if (frh->action != FR_ACT_TO_TBL)
                return 0;