]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: add debug routine to display which PBR entry is handled
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 11 Jun 2018 13:41:57 +0000 (15:41 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 2 Jul 2018 07:20:39 +0000 (09:20 +0200)
To know which entry is set/unset, a debug handler is present, that
displays which entry is injected/removed to/from zebra.

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

index 47f12d23d49e688751151aefd8beab9dc433ffba..5baba4cbb222c09dbf3cbf819f94d854a7b53c34 100644 (file)
@@ -1126,6 +1126,56 @@ static void bgp_pbr_policyroute_add_to_zebra(struct bgp *bgp,
        struct bgp_pbr_action *bpa = NULL;
        struct bgp_pbr_match_entry_remain bpmer;
 
+       if (BGP_DEBUG(zebra, ZEBRA)) {
+               char bufsrc[64], bufdst[64];
+               char buffer[64];
+               int remaining_len = 0;
+               char protocol_str[16];
+
+               protocol_str[0] = '\0';
+               if (protocol)
+                       snprintf(protocol_str, sizeof(protocol),
+                                "proto %d", protocol);
+               buffer[0] = '\0';
+               if (protocol == IPPROTO_ICMP && src_port && dst_port)
+                       remaining_len += snprintf(buffer, 64, "type %d, code %d",
+                                src_port->min_port, dst_port->min_port);
+               else if ( protocol == IPPROTO_UDP || protocol == IPPROTO_TCP) {
+
+                       if (src_port && src_port->min_port)
+                               remaining_len += snprintf(buffer,
+                                                         sizeof(buffer),
+                                                         "from [%u:%u]",
+                                                         src_port->min_port,
+                                                         src_port->max_port ?
+                                                         src_port->max_port :
+                                                         src_port->min_port);
+                       if (dst_port && dst_port->min_port)
+                               remaining_len += snprintf(buffer +
+                                                         remaining_len,
+                                                         sizeof(buffer)
+                                                         - remaining_len,
+                                                         "to [%u:%u]",
+                                                         dst_port->min_port,
+                                                         dst_port->max_port ?
+                                                         dst_port->max_port :
+                                                         dst_port->min_port);
+               }
+               if (pkt_len && (pkt_len->min_port || pkt_len->max_port)) {
+                       remaining_len += snprintf(buffer + remaining_len,
+                                                 sizeof(buffer)
+                                                 - remaining_len,
+                                                 " len [%u:%u]",
+                                                 pkt_len->min_port,
+                                                 pkt_len->max_port ?
+                                                 pkt_len->max_port :
+                                                 pkt_len->min_port);
+               }
+               zlog_info("BGP: adding FS PBR from %s to %s, %s %s",
+                         src == NULL ? "<all>" : prefix2str(src, bufsrc, 64),
+                         dst == NULL ? "<all>" : prefix2str(dst, bufdst, 64),
+                         protocol_str, buffer);
+       }
        /* look for bpa first */
        memset(&temp3, 0, sizeof(temp3));
        if (rate)