]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: change priority of fs pbr rules
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 30 Nov 2018 13:13:37 +0000 (14:13 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 29 Jan 2019 13:15:10 +0000 (14:15 +0100)
two kind of rules are being set from bgp flowspec: ipset based rules,
and ip rule rules. default route rules may have a lower priority than
the other rules ( that do not support default rules). so, if an ipset
rule without fwmark is being requested, then priority is arbitrarily set
to 1. the other case, priority is set to 0.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_pbr.c
bgpd/bgp_pbr.h
bgpd/bgp_zebra.c

index 890fb64313d41631baebee4aa4b2a6de090fd7dd..9a6ada2058c56ed873df64f53237d29ba3b52252 100644 (file)
@@ -2030,6 +2030,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
        if (bpf->type == BGP_PBR_IPRULE) {
                memset(&pbr_rule, 0, sizeof(pbr_rule));
                pbr_rule.vrf_id = bpf->vrf_id;
+               pbr_rule.priority = 20;
                if (bpf->src) {
                        pbr_rule.flags |= MATCH_IP_SRC_SET;
                        prefix_copy(&pbr_rule.src, bpf->src);
index c3db10cbe7dfd95c12c7728dae1256d15da8f15a..da21e0f9c4eeba502b7d08ea0d2e40c07f4f8a86 100644 (file)
@@ -165,6 +165,7 @@ struct bgp_pbr_rule {
        struct bgp_pbr_action *action;
        vrf_id_t vrf_id;
        uint32_t unique;
+       uint32_t priority;
        bool installed;
        bool install_in_progress;
 };
index 9212c36dd5e1cc1a2217c962f2f3099161d5ce4f..4513086ad06cbf9bd679f3ca2db7ee2539becc1d 100644 (file)
@@ -2270,8 +2270,16 @@ static void bgp_encode_pbr_rule_action(struct stream *s,
        struct prefix pfx;
 
        stream_putl(s, 0); /* seqno unused */
-       stream_putl(s, 0); /* ruleno unused */
-
+       if (pbr)
+               stream_putl(s, pbr->priority);
+       else
+               stream_putl(s, 0);
+       /* ruleno unused - priority change
+        * ruleno permits distinguishing various FS PBR entries
+        * - FS PBR entries based on ipset/iptables
+        * - FS PBR entries based on iprule
+        * the latter may contain default routing information injected by FS
+        */
        if (pbr)
                stream_putl(s, pbr->unique);
        else