BGP: Simplify igp table options

This commit is contained in:
Ondrej Zajicek (work) 2017-03-29 15:31:04 +02:00
parent c49e4a6565
commit 6fe11c9941
2 changed files with 16 additions and 4 deletions

View file

@ -1656,6 +1656,7 @@ bgp_postconfig(struct proto_config *CF)
if (cc->gr_able == 0xff) if (cc->gr_able == 0xff)
cc->gr_able = (cf->gr_mode == BGP_GR_ABLE); cc->gr_able = (cf->gr_mode == BGP_GR_ABLE);
/* Default values of IGP tables */
if ((cc->gw_mode == GW_RECURSIVE) && !cc->desc->no_igp) if ((cc->gw_mode == GW_RECURSIVE) && !cc->desc->no_igp)
{ {
if (!cc->igp_table_ip4 && (bgp_cc_is_ipv4(cc) || cc->ext_next_hop)) if (!cc->igp_table_ip4 && (bgp_cc_is_ipv4(cc) || cc->ext_next_hop))
@ -1663,6 +1664,12 @@ bgp_postconfig(struct proto_config *CF)
if (!cc->igp_table_ip6 && (bgp_cc_is_ipv6(cc) || cc->ext_next_hop)) if (!cc->igp_table_ip6 && (bgp_cc_is_ipv6(cc) || cc->ext_next_hop))
cc->igp_table_ip6 = bgp_default_igp_table(cf, cc, NET_IP6); cc->igp_table_ip6 = bgp_default_igp_table(cf, cc, NET_IP6);
if (cc->igp_table_ip4 && bgp_cc_is_ipv6(cc) && !cc->ext_next_hop)
cf_error("Mismatched IGP table type");
if (cc->igp_table_ip6 && bgp_cc_is_ipv4(cc) && !cc->ext_next_hop)
cf_error("Mismatched IGP table type");
} }
if (cf->multihop && (cc->gw_mode == GW_DIRECT)) if (cf->multihop && (cc->gw_mode == GW_DIRECT))

View file

@ -179,11 +179,16 @@ bgp_channel_item:
| ADD PATHS TX { BGP_CC->add_path = BGP_ADD_PATH_TX; } | ADD PATHS TX { BGP_CC->add_path = BGP_ADD_PATH_TX; }
| ADD PATHS bool { BGP_CC->add_path = $3 ? BGP_ADD_PATH_FULL : 0; } | ADD PATHS bool { BGP_CC->add_path = $3 ? BGP_ADD_PATH_FULL : 0; }
| IGP TABLE rtable { | IGP TABLE rtable {
if (bgp_cc_is_ipv4(BGP_CC)) BGP_CC->igp_table_ip4 = $3; if (BGP_CC->desc->no_igp)
if (bgp_cc_is_ipv6(BGP_CC)) BGP_CC->igp_table_ip6 = $3; cf_error("IGP table not allowed here");
if ($3->addr_type == NET_IP4)
BGP_CC->igp_table_ip4 = $3;
else if ($3->addr_type == NET_IP6)
BGP_CC->igp_table_ip6 = $3;
else
cf_error("Mismatched IGP table type");
} }
| IGP TABLE IPV4 rtable { BGP_CC->igp_table_ip4 = $4; }
| IGP TABLE IPV6 rtable { BGP_CC->igp_table_ip6 = $4; }
; ;
bgp_channel_opts: bgp_channel_opts: