Skip to content

Commit

Permalink
Merge pull request #537 from donaldsharp/vrf_stuff
Browse files Browse the repository at this point in the history
Vrf stuff
  • Loading branch information
eqvinox authored May 17, 2017
2 parents e89f016 + 910a5c0 commit bac7b7b
Show file tree
Hide file tree
Showing 36 changed files with 230 additions and 273 deletions.
3 changes: 1 addition & 2 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,8 +1480,7 @@ bgp_attr_as4_path (struct bgp_attr_parser_args *args, struct aspath **as4_path)
}

/* Set aspath attribute flag. */
if (as4_path)
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS4_PATH);
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS4_PATH);

return BGP_ATTR_PARSE_PROCEED;
}
Expand Down
18 changes: 7 additions & 11 deletions bgpd/bgp_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,16 +1158,13 @@ extcommunity_list_set (struct community_list_handler *ch,
}
}

if (str)
{
if (style == EXTCOMMUNITY_LIST_STANDARD)
ecom = ecommunity_str2com (str, 0, 1);
else
regex = bgp_regcomp (str);
if (style == EXTCOMMUNITY_LIST_STANDARD)
ecom = ecommunity_str2com (str, 0, 1);
else
regex = bgp_regcomp (str);

if (! ecom && ! regex)
return COMMUNITY_LIST_ERR_MALFORMED_VAL;
}
if (! ecom && ! regex)
return COMMUNITY_LIST_ERR_MALFORMED_VAL;

if (ecom)
ecom->str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY, 0);
Expand All @@ -1180,8 +1177,7 @@ extcommunity_list_set (struct community_list_handler *ch,
entry->config = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST, 0);
else if (regex)
entry->config = XSTRDUP (MTYPE_COMMUNITY_LIST_CONFIG, str);
else
entry->config = NULL;

entry->u.ecom = ecom;
entry->reg = regex;

Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ bgp_dump_parse_time (const char *str)
return 0;
total += time * 60;
time = 0;
seen_h = 1;
seen_m = 1;
}
else
return 0;
Expand Down
15 changes: 4 additions & 11 deletions bgpd/bgp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,15 @@ bgp_vrf_disable (struct vrf *vrf)
static void
bgp_vrf_init (void)
{
vrf_add_hook (VRF_NEW_HOOK, bgp_vrf_new);
vrf_add_hook (VRF_ENABLE_HOOK, bgp_vrf_enable);
vrf_add_hook (VRF_DISABLE_HOOK, bgp_vrf_disable);
vrf_add_hook (VRF_DELETE_HOOK, bgp_vrf_delete);

vrf_init ();
vrf_init (bgp_vrf_new,
bgp_vrf_enable,
bgp_vrf_disable,
bgp_vrf_delete);
}

static void
bgp_vrf_terminate (void)
{
vrf_add_hook (VRF_NEW_HOOK, NULL);
vrf_add_hook (VRF_ENABLE_HOOK, NULL);
vrf_add_hook (VRF_DISABLE_HOOK, NULL);
vrf_add_hook (VRF_DELETE_HOOK, NULL);

vrf_terminate ();
}

Expand Down
10 changes: 7 additions & 3 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -8887,6 +8887,7 @@ bgp_show_community (struct vty *vty, struct bgp *bgp, int argc,
int i;
char *str;
int first = 0;
int ret = 0;

b = buffer_new (1024);
for (i = 0; i < argc; i++)
Expand Down Expand Up @@ -8915,9 +8916,12 @@ bgp_show_community (struct vty *vty, struct bgp *bgp, int argc,
return CMD_WARNING;
}

return bgp_show (vty, bgp, afi, safi,
(exact ? bgp_show_type_community_exact :
bgp_show_type_community), com, 0);
ret = bgp_show (vty, bgp, afi, safi,
(exact ? bgp_show_type_community_exact :
bgp_show_type_community), com, 0);
community_free (com);

return ret;
}

static int
Expand Down
19 changes: 1 addition & 18 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ struct community_list_handler *bgp_clist;

unsigned int multipath_num = MULTIPATH_NUM;

static void bgp_if_init (struct bgp *bgp);
static void bgp_if_finish (struct bgp *bgp);

extern struct zclient *zclient;
Expand Down Expand Up @@ -3115,10 +3114,7 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name,

vrf = bgp_vrf_lookup_by_instance_type (bgp);
if (vrf)
{
bgp_vrf_link (bgp, vrf);
bgp_if_init (bgp);
}
bgp_vrf_link (bgp, vrf);
}

/* Register with Zebra, if needed */
Expand Down Expand Up @@ -7654,19 +7650,6 @@ bgp_master_init (struct thread_master *master)
QOBJ_REG (bm, bgp_master);
}

/*
* Initialize interface list for instance, if needed. Invoked upon
* instance create.
*/
static void
bgp_if_init (struct bgp *bgp)
{
if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
return;

vrf_iflist_create (bgp->vrf_id);
}

/*
* Free up connected routes and interfaces for a BGP instance. Invoked upon
* instance delete (non-default only) or BGP exit.
Expand Down
12 changes: 9 additions & 3 deletions eigrpd/eigrp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,16 @@ show_ip_eigrp_topology_header (struct vty *vty, struct eigrp *eigrp)
void
show_ip_eigrp_prefix_entry (struct vty *vty, struct eigrp_prefix_entry *tn)
{
struct list *successors = eigrp_topology_get_successor(tn);

vty_out (vty, "%-3c",(tn->state > 0) ? 'A' : 'P');
vty_out (vty, "%s/%u, ",inet_ntoa (tn->destination_ipv4->prefix),tn->destination_ipv4->prefixlen);
vty_out (vty, "%u successors, ",eigrp_topology_get_successor(tn)->count);
vty_out (vty, "FD is %u, serno: %" PRIu64 " %s",tn->fdistance, tn->serno, VTY_NEWLINE);

vty_out (vty, "%s/%u, ",
inet_ntoa (tn->destination_ipv4->prefix), tn->destination_ipv4->prefixlen);
vty_out (vty, "%u successors, ", successors->count);
vty_out (vty, "FD is %u, serno: %" PRIu64 " %s", tn->fdistance, tn->serno, VTY_NEWLINE);

list_delete(successors);
}

void
Expand Down
17 changes: 1 addition & 16 deletions eigrpd/eigrp_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ eigrp_distribute_update (struct distribute *dist)
if (dist->list[DISTRIBUTE_V4_IN])
{
alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_IN]);
zlog_info("<DEBUG DISTRIBUTE ACL IN FOUND: %s",alist->name);
if (alist)
e->list[EIGRP_FILTER_IN] = alist;
else
Expand All @@ -96,7 +95,6 @@ eigrp_distribute_update (struct distribute *dist)
/* access list OUT for whole process */
if (dist->list[DISTRIBUTE_V4_OUT])
{
zlog_info("<DEBUG DISTRIBUTE ACL OUT FOUND: %s",dist->list[DISTRIBUTE_V4_OUT]);
alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_OUT]);
if (alist)
e->list[EIGRP_FILTER_OUT] = alist;
Expand All @@ -111,7 +109,6 @@ eigrp_distribute_update (struct distribute *dist)
/* PREFIX_LIST IN for process */
if (dist->prefix[DISTRIBUTE_V4_IN])
{
zlog_info("<DEBUG DISTRIBUTE PREFIX IN FOUND: %s",dist->prefix[DISTRIBUTE_V4_IN]);
plist = prefix_list_lookup (AFI_IP, dist->prefix[DISTRIBUTE_V4_IN]);
if (plist)
{
Expand All @@ -125,7 +122,6 @@ eigrp_distribute_update (struct distribute *dist)
/* PREFIX_LIST OUT for process */
if (dist->prefix[DISTRIBUTE_V4_OUT])
{
zlog_info("<DEBUG DISTRIBUTE PREFIX OUT FOUND: %s",dist->prefix[DISTRIBUTE_V4_OUT]);
plist = prefix_list_lookup (AFI_IP, dist->prefix[DISTRIBUTE_V4_OUT]);
if (plist)
{
Expand Down Expand Up @@ -191,8 +187,6 @@ eigrp_distribute_update (struct distribute *dist)
if (ifp == NULL)
return;

zlog_info("<DEBUG ACL 2");

/*struct eigrp_if_info * info = ifp->info;
ei = info->eigrp_interface;*/
struct listnode *node, *nnode;
Expand All @@ -206,15 +200,9 @@ eigrp_distribute_update (struct distribute *dist)
}
}

if(ei == NULL)
{
zlog_info("Not Found eigrp interface %s",ifp->name);
}

/* Access-list for interface in */
if (dist->list[DISTRIBUTE_V4_IN])
{
zlog_info("<DEBUG ACL in");
alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_IN]);
if (alist){
ei->list[EIGRP_FILTER_IN] = alist;
Expand All @@ -238,10 +226,7 @@ eigrp_distribute_update (struct distribute *dist)

}
else
{
ei->list[EIGRP_FILTER_OUT] = NULL;
zlog_info("<DEBUG ACL out else");
}
ei->list[EIGRP_FILTER_OUT] = NULL;

/* Prefix-list for interface in */
if (dist->prefix[DISTRIBUTE_V4_IN])
Expand Down
15 changes: 9 additions & 6 deletions eigrpd/eigrp_hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ eigrp_peer_termination_decode (struct eigrp_neighbor *nbr,
if(my_ip == received_ip)
{
zlog_info ("Neighbor %s (%s) is down: Peer Termination received",
inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
inet_ntoa (nbr->src),
ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
/* set neighbor to DOWN */
nbr->state = EIGRP_NEIGHBOR_DOWN;
/* delete neighbor */
Expand Down Expand Up @@ -363,14 +364,15 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
case EIGRP_TLV_SW_VERSION:
eigrp_sw_version_decode(nbr, tlv_header);
break;
case EIGRP_TLV_NEXT_MCAST_SEQ:
break;
case EIGRP_TLV_NEXT_MCAST_SEQ:
break;
case EIGRP_TLV_PEER_TERMINATION:
eigrp_peer_termination_decode(nbr, tlv_header);
return;
break;
case EIGRP_TLV_PEER_MTRLIST:
case EIGRP_TLV_PEER_TIDLIST:
break;
case EIGRP_TLV_PEER_TIDLIST:
break;
default:
break;
}
Expand All @@ -387,7 +389,8 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
{
/* increment statistics. */
ei->hello_in++;
eigrp_nbr_state_update(nbr);
if (nbr)
eigrp_nbr_state_update(nbr);

}

Expand Down
4 changes: 3 additions & 1 deletion eigrpd/eigrp_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ eigrp_if_up (struct eigrp_interface *ei)
{
pe = eigrp_prefix_entry_new ();
pe->serno = eigrp->serno;
pe->destination_ipv4 = dest_addr;
pe->destination_ipv4 = prefix_ipv4_new ();
prefix_copy ((struct prefix *)pe->destination_ipv4,
(struct prefix *)&dest_addr);
pe->af = AF_INET;
pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;

Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ main (int argc, char **argv, char **envp)
eigrp_om->master = frr_init();
master = eigrp_om->master;

vrf_init ();
vrf_init (NULL, NULL, NULL, NULL);

/*EIGRPd init*/
eigrp_if_init ();
Expand Down
14 changes: 8 additions & 6 deletions eigrpd/eigrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ eigrp_make_md5_digest (struct eigrp_interface *ei, struct stream *s, u_char flag
if(keychain)
key = key_lookup_for_send(keychain);
else
return EIGRP_AUTH_TYPE_NONE;
{
eigrp_authTLV_MD5_free(auth_TLV);
return EIGRP_AUTH_TYPE_NONE;
}

memset(&ctx, 0, sizeof(ctx));
MD5Init(&ctx);
Expand Down Expand Up @@ -234,8 +237,7 @@ eigrp_check_md5_digest (struct stream *s,
}

/* save neighbor's crypt_seqnum */
if (nbr)
nbr->crypt_seqnum = authTLV->key_sequence;
nbr->crypt_seqnum = authTLV->key_sequence;

return 1;
}
Expand Down Expand Up @@ -627,7 +629,7 @@ eigrp_read (struct thread *thread)
struct eigrp_packet *ep;

ep = eigrp_fifo_tail(nbr->retrans_queue);
if (ep != NULL)
if (ep)
{
if (ntohl(eigrph->ack) == ep->sequence_number)
{
Expand All @@ -641,15 +643,15 @@ eigrp_read (struct thread *thread)
eigrp_update_send_EOT(nbr);
}
ep = eigrp_fifo_pop_tail(nbr->retrans_queue);
/*eigrp_packet_free(ep);*/
eigrp_packet_free(ep);
if (nbr->retrans_queue->count > 0)
{
eigrp_send_packet_reliably(nbr);
}
}
}
ep = eigrp_fifo_tail(nbr->multicast_queue);
if (ep != NULL)
if (ep)
{
if (ntohl(eigrph->ack) == ep->sequence_number)
{
Expand Down
11 changes: 6 additions & 5 deletions eigrpd/eigrp_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,17 @@ eigrp_query_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
type = stream_getw(s);
if (type == EIGRP_TLV_IPv4_INT)
{
struct prefix_ipv4 dest_addr;

stream_set_getp(s, s->getp - sizeof(u_int16_t));

tlv = eigrp_read_ipv4_tlv(s);

struct prefix_ipv4 *dest_addr;
dest_addr = prefix_ipv4_new();
dest_addr->prefix = tlv->destination;
dest_addr->prefixlen = tlv->prefix_length;
dest_addr.family = AFI_IP;
dest_addr.prefix = tlv->destination;
dest_addr.prefixlen = tlv->prefix_length;
struct eigrp_prefix_entry *dest =
eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr);
eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr);

/* If the destination exists (it should, but one never know)*/
if (dest != NULL)
Expand Down
Loading

0 comments on commit bac7b7b

Please sign in to comment.