From 5ee62c66a95b9358275e8c883aed5c68b644dcca Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 4 Nov 2016 09:47:36 -0700 Subject: [PATCH] BGP: deal with vnc related string ambiguities (issue #9) - "redist foo" parsing modified to check for foo==vnc and foo==vnc-direct instead of just leading 'v' character - string designating ZEBRA_ROUTE_VNC_DIRECT changed from "vpn" to "vnc-direct" - route_types.pl parser recognizes 7th field to restrict availability of a route type in the redist command to specific daemons - restrict "vnc-direct" to bgpd only (doesn't make sense elsewhere) - vnc documentation updated to match Signed-off-by: Lou Berger --- doc/vnc.texi | 4 ++-- lib/log.c | 12 ++++++------ lib/route_types.pl | 5 ++++- lib/route_types.txt | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/doc/vnc.texi b/doc/vnc.texi index 341cbfcce8..b0d2829cae 100644 --- a/doc/vnc.texi +++ b/doc/vnc.texi @@ -726,7 +726,7 @@ provided to other protocols, either via zebra or directly to BGP. It is important to note that when exporting routes to other protocols, the downstream protocol must also be configured to import the routes. For example, when VNC routes are exported to unicast BGP, the BGP -configuration must include a corresponding @code{redistribute vpn} +configuration must include a corresponding @code{redistribute vnc-direct} statement. @deffn {VNC} {export bgp|zebra mode none|group-nve|registering-nve|ce} @@ -1115,7 +1115,7 @@ The configuration for @code{VNC-GW 1} is shown below. router bgp 64512 bgp router-id 192.168.1.101 bgp cluster-id 1.2.3.4 - redistribute vpn + redistribute vnc-direct neighbor 192.168.1.102 remote-as 64512 no neighbor 192.168.1.102 activate neighbor 192.168.1.103 remote-as 64512 diff --git a/lib/log.c b/lib/log.c index f9877300b4..a0902b5d0d 100644 --- a/lib/log.c +++ b/lib/log.c @@ -1077,10 +1077,10 @@ proto_redistnum(int afi, const char *s) return ZEBRA_ROUTE_BGP; else if (strncmp (s, "ta", 2) == 0) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) - return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strcmp (s, "vnc-direct") == 0) return ZEBRA_ROUTE_VNC_DIRECT; + else if (strcmp (s, "vnc") == 0) + return ZEBRA_ROUTE_VNC; } if (afi == AFI_IP6) { @@ -1100,10 +1100,10 @@ proto_redistnum(int afi, const char *s) return ZEBRA_ROUTE_BGP; else if (strncmp (s, "ta", 2) == 0) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) - return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strcmp (s, "vnc-direct") == 0) return ZEBRA_ROUTE_VNC_DIRECT; + else if (strcmp (s, "vnc") == 0) + return ZEBRA_ROUTE_VNC; } return -1; } diff --git a/lib/route_types.pl b/lib/route_types.pl index d44cb12b23..7e99fdde09 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -56,7 +56,7 @@ while () { # else: 7-field line my @f = split(/,/, $_); - unless (@f == 7) { + unless (@f == 7 || @f == 8) { die "invalid input on route_types line $.\n"; } @@ -73,6 +73,7 @@ while () { "ipv4" => int($f[4]), "ipv6" => int($f[5]), "shorthelp" => $f[6], + "restrict2" => $f[7], }; push @protos, $proto; $daemons{$f[2]} = { @@ -137,6 +138,8 @@ sub collect { my (@names, @help) = ((), ()); for my $p (@protos) { next if ($protodetail{$p}->{"daemon"} eq $daemon && $daemon ne "zebra"); + next if ($protodetail{$p}->{"restrict2"} ne "" && + $protodetail{$p}->{"restrict2"} ne $daemon); next unless (($ipv4 && $protodetail{$p}->{"ipv4"}) || ($ipv6 && $protodetail{$p}->{"ipv6"})); push @names, $protodetail{$p}->{"cname"}; diff --git a/lib/route_types.txt b/lib/route_types.txt index 54572450b5..154f03f01c 100644 --- a/lib/route_types.txt +++ b/lib/route_types.txt @@ -64,9 +64,9 @@ ZEBRA_ROUTE_LDP, ldp, ldpd, 'L', 0, 0, "LDP" #vnc when sent to zebra ZEBRA_ROUTE_VNC, vnc, NULL, 'v', 1, 1, "VNC" # vnc when sent to bgp -ZEBRA_ROUTE_VNC_DIRECT, vpn, NULL, 'V', 1, 1, "VPN" -# vnc when sent to bgp (remote next hop?) -ZEBRA_ROUTE_VNC_DIRECT_RH, vpn-rh, NULL, 'V', 0, 0, "VPN" +ZEBRA_ROUTE_VNC_DIRECT, vnc-direct,NULL, 'V', 1, 1, "VNC-Direct", bgpd +# vnc when sent to bgp (resolve NVE mode) +ZEBRA_ROUTE_VNC_DIRECT_RH, vnc-rn, NULL, 'V', 0, 0, "VNC-RN" # bgp unicast -> vnc ZEBRA_ROUTE_BGP_DIRECT, bgp-direct, NULL, 'b', 0, 0, "BGP-Direct" # bgp unicast -> vnc @@ -90,4 +90,4 @@ ZEBRA_ROUTE_VNC, "Virtual Network Control (VNC)" ZEBRA_ROUTE_OLSR, "Optimised Link State Routing (OLSR)" ZEBRA_ROUTE_TABLE, "Non-main Kernel Routing Table" ZEBRA_ROUTE_LDP, "Label Distribution Protocol (LDP)" -ZEBRA_ROUTE_VNC_DIRECT, "VPN routes(VPN)" +ZEBRA_ROUTE_VNC_DIRECT, "VNC direct (not via zebra) routes"