version 1.1.1.2, 2012/10/09 09:22:28
|
version 1.1.1.3, 2013/07/21 23:54:38
|
Line 111 route_match_peer (void *rule, struct prefix *prefix, r
|
Line 111 route_match_peer (void *rule, struct prefix *prefix, r
|
void *object) |
void *object) |
{ |
{ |
union sockunion *su; |
union sockunion *su; |
union sockunion *su2; | union sockunion su_def = { .sa.sa_family = AF_INET, |
| .sin.sin_addr.s_addr = INADDR_ANY }; |
struct peer_group *group; |
struct peer_group *group; |
struct peer *peer; |
struct peer *peer; |
struct listnode *node, *nnode; |
struct listnode *node, *nnode; |
Line 127 route_match_peer (void *rule, struct prefix *prefix, r
|
Line 128 route_match_peer (void *rule, struct prefix *prefix, r
|
|
|
/* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK, |
/* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK, |
REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */ |
REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */ |
su2 = sockunion_str2su ("0.0.0.0"); | if (sockunion_same (su, &su_def)) |
if ( sockunion_same (su, su2) ) | |
{ |
{ |
int ret; |
int ret; |
if ( CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_NETWORK) || |
if ( CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_NETWORK) || |
Line 137 route_match_peer (void *rule, struct prefix *prefix, r
|
Line 137 route_match_peer (void *rule, struct prefix *prefix, r
|
ret = RMAP_MATCH; |
ret = RMAP_MATCH; |
else |
else |
ret = RMAP_NOMATCH; |
ret = RMAP_NOMATCH; |
|
|
sockunion_free (su2); |
|
return ret; |
return ret; |
} |
} |
sockunion_free (su2); | |
| |
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
{ |
{ |
if (sockunion_same (su, &peer->su)) |
if (sockunion_same (su, &peer->su)) |
Line 172 route_match_peer_compile (const char *arg)
|
Line 169 route_match_peer_compile (const char *arg)
|
|
|
su = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union sockunion)); |
su = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union sockunion)); |
|
|
ret = str2sockunion ( (arg)? arg : "0.0.0.0", su); | ret = str2sockunion (strcmp(arg, "local") ? arg : "0.0.0.0", su); |
if (ret < 0) { |
if (ret < 0) { |
XFREE (MTYPE_ROUTE_MAP_COMPILED, su); |
XFREE (MTYPE_ROUTE_MAP_COMPILED, su); |
return NULL; |
return NULL; |
Line 878 route_set_ip_nexthop (void *rule, struct prefix *prefi
|
Line 875 route_set_ip_nexthop (void *rule, struct prefix *prefi
|
route_map_object_t type, void *object) |
route_map_object_t type, void *object) |
{ |
{ |
struct rmap_ip_nexthop_set *rins = rule; |
struct rmap_ip_nexthop_set *rins = rule; |
struct in_addr peer_address; |
|
struct bgp_info *bgp_info; |
struct bgp_info *bgp_info; |
struct peer *peer; |
struct peer *peer; |
|
|
Line 894 route_set_ip_nexthop (void *rule, struct prefix *prefi
|
Line 890 route_set_ip_nexthop (void *rule, struct prefix *prefi
|
&& peer->su_remote |
&& peer->su_remote |
&& sockunion_family (peer->su_remote) == AF_INET) |
&& sockunion_family (peer->su_remote) == AF_INET) |
{ |
{ |
inet_aton (sockunion_su2str (peer->su_remote), &peer_address); | bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_remote); |
bgp_info->attr->nexthop = peer_address; | |
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
} |
} |
else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT) |
else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT) |
&& peer->su_local |
&& peer->su_local |
&& sockunion_family (peer->su_local) == AF_INET) |
&& sockunion_family (peer->su_local) == AF_INET) |
{ |
{ |
inet_aton (sockunion_su2str (peer->su_local), &peer_address); | bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_local); |
bgp_info->attr->nexthop = peer_address; | |
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
} |
} |
} |
} |
Line 1353 route_set_community (void *rule, struct prefix *prefix
|
Line 1347 route_set_community (void *rule, struct prefix *prefix
|
{ |
{ |
attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)); |
attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)); |
attr->community = NULL; |
attr->community = NULL; |
|
/* See the longer comment down below. */ |
|
if (old && old->refcnt == 0) |
|
community_free(old); |
return RMAP_OKAY; |
return RMAP_OKAY; |
} |
} |
|
|
Line 2430 DEFUN (match_peer_local,
|
Line 2427 DEFUN (match_peer_local,
|
"Match peer address\n" |
"Match peer address\n" |
"Static or Redistributed routes\n") |
"Static or Redistributed routes\n") |
{ |
{ |
return bgp_route_match_add (vty, vty->index, "peer", NULL); | return bgp_route_match_add (vty, vty->index, "peer", "local"); |
} |
} |
|
|
DEFUN (no_match_peer, |
DEFUN (no_match_peer, |