]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add packet length into pbr support
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 11 Jun 2018 13:30:11 +0000 (15:30 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 28 Jun 2018 06:52:15 +0000 (08:52 +0200)
The packet length is added to iptable zapi message.
Then the iptable structure is taking into account the pkt_len field.
The show pbr iptable command displays the packet length used if any.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/zapi_msg.c
zebra/zebra_pbr.c
zebra/zebra_pbr.h

index b07c5662492422e6a51074bf84936a24df73ed06..39667a7f8bf52665374fcaa82bdf608b2559e61a 100644 (file)
@@ -2938,6 +2938,8 @@ static inline void zread_iptable(ZAPI_HANDLER_ARGS)
        STREAM_GETL(s, zpi.action);
        STREAM_GETL(s, zpi.fwmark);
        STREAM_GET(&zpi.ipset_name, s, ZEBRA_IPSET_NAME_SIZE);
+       STREAM_GETW(s, zpi.pkt_len_min);
+       STREAM_GETW(s, zpi.pkt_len_max);
        STREAM_GETL(s, zpi.nb_interface);
        zebra_pbr_iptable_update_interfacelist(s, &zpi);
 
index daf384c8364aa28b3305f0a5d964377ad6fe1b1c..10043376024acd86431ad9251385b2ffc0db4e41 100644 (file)
@@ -360,6 +360,8 @@ uint32_t zebra_pbr_iptable_hash_key(void *arg)
        key = jhash2(pnt, ZEBRA_IPSET_NAME_HASH_SIZE,
                     0x63ab42de);
        key = jhash_1word(iptable->fwmark, key);
+       key = jhash_1word(iptable->pkt_len_min, key);
+       key = jhash_1word(iptable->pkt_len_max, key);
        return jhash_3words(iptable->filter_bm, iptable->type,
                            iptable->unique, key);
 }
@@ -384,6 +386,10 @@ int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
        if (strncmp(r1->ipset_name, r2->ipset_name,
                    ZEBRA_IPSET_NAME_SIZE))
                return 0;
+       if (r1->pkt_len_min != r2->pkt_len_min)
+               return 0;
+       if (r1->pkt_len_max != r2->pkt_len_max)
+               return 0;
        return 1;
 }
 
@@ -1016,7 +1022,15 @@ static int zebra_pbr_show_iptable_walkcb(struct hash_backet *backet, void *arg)
        vty_out(vty, "IPtable %s action %s (%u)\n", iptable->ipset_name,
                iptable->action == ZEBRA_IPTABLES_DROP ? "drop" : "redirect",
                iptable->unique);
-
+       if (iptable->pkt_len_min || iptable->pkt_len_max) {
+               if (!iptable->pkt_len_max)
+                       vty_out(vty, "\t pkt len %u\n",
+                               iptable->pkt_len_min);
+               else
+                       vty_out(vty, "\t pkt len [%u;%u]\n",
+                               iptable->pkt_len_min,
+                               iptable->pkt_len_max);
+       }
        ret = hook_call(zebra_pbr_iptable_wrap_script_get_stat,
                        zns, iptable, &pkts, &bytes);
        if (ret && pkts > 0)
index 71b5c4cd5af80fb2675f8aed57812878644f5e3b..c7e3f0d10983e73426d897bf9a31e5c267411a01 100644 (file)
@@ -133,6 +133,9 @@ struct zebra_pbr_iptable {
 
        uint32_t action;
 
+       uint16_t pkt_len_min;
+       uint16_t pkt_len_max;
+
        uint32_t nb_interface;
 
        struct list *interface_name_list;