type
stringclasses 5
values | content
stringlengths 9
163k
|
|---|---|
functions
|
int
peer_default_originate_set (struct peer *peer, afi_t afi, safi_t safi,
const char *rmap)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* Default originate can't be used for peer group memeber. */
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)
|| (rmap && ! peer->default_rmap[afi][safi].name)
|| (rmap && strcmp (rmap, peer->default_rmap[afi][safi].name) != 0))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
if (rmap)
{
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = strdup (rmap);
peer->default_rmap[afi][safi].map = route_map_lookup_by_name (rmap);
}
|
functions
|
int
peer_default_originate_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* Default originate can't be used for peer group memeber. */
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
{
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = NULL;
peer->default_rmap[afi][safi].map = NULL;
}
|
functions
|
int
peer_port_set (struct peer *peer, u_int16_t port)
{
peer->port = port;
return 0;
}
|
functions
|
int
peer_port_unset (struct peer *peer)
{
peer->port = BGP_PORT_DEFAULT;
return 0;
}
|
functions
|
int
peer_weight_set (struct peer *peer, u_int16_t weight)
{
struct peer_group *group;
struct listnode *node, *nnode;
SET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
peer->weight = weight;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = group->conf->weight;
}
|
functions
|
int
peer_weight_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Set default weight. */
if (peer_group_active (peer))
peer->weight = peer->group->conf->weight;
else
peer->weight = 0;
UNSET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = 0;
}
|
functions
|
int
peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Not for peer group memeber. */
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* keepalive value check. */
if (keepalive > 65535)
return BGP_ERR_INVALID_VALUE;
/* Holdtime value check. */
if (holdtime > 65535)
return BGP_ERR_INVALID_VALUE;
/* Holdtime value must be either 0 or greater than 3. */
if (holdtime < 3 && holdtime != 0)
return BGP_ERR_INVALID_VALUE;
/* Set value to the configuration. */
SET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = holdtime;
peer->keepalive = (keepalive < holdtime / 3 ? keepalive : holdtime / 3);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = group->conf->holdtime;
peer->keepalive = group->conf->keepalive;
}
|
functions
|
int
peer_timers_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* Clear configuration. */
UNSET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->keepalive = 0;
peer->holdtime = 0;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = 0;
peer->keepalive = 0;
}
|
functions
|
int
peer_timers_connect_set (struct peer *peer, u_int32_t connect)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (connect > 65535)
return BGP_ERR_INVALID_VALUE;
/* Set value to the configuration. */
SET_FLAG (peer->config, PEER_CONFIG_CONNECT);
peer->connect = connect;
/* Set value to timer setting. */
peer->v_connect = connect;
return 0;
}
|
functions
|
int
peer_timers_connect_unset (struct peer *peer)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* Clear configuration. */
UNSET_FLAG (peer->config, PEER_CONFIG_CONNECT);
peer->connect = 0;
/* Set timer setting to default value. */
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
return 0;
}
|
functions
|
int
peer_advertise_interval_set (struct peer *peer, u_int32_t routeadv)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (routeadv > 600)
return BGP_ERR_INVALID_VALUE;
SET_FLAG (peer->config, PEER_CONFIG_ROUTEADV);
peer->routeadv = routeadv;
peer->v_routeadv = routeadv;
return 0;
}
|
functions
|
int
peer_advertise_interval_unset (struct peer *peer)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
UNSET_FLAG (peer->config, PEER_CONFIG_ROUTEADV);
peer->routeadv = 0;
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
return 0;
}
|
functions
|
int
peer_interface_set (struct peer *peer, const char *str)
{
if (peer->ifname)
free (peer->ifname);
peer->ifname = strdup (str);
return 0;
}
|
functions
|
int
peer_interface_unset (struct peer *peer)
{
if (peer->ifname)
free (peer->ifname);
peer->ifname = NULL;
return 0;
}
|
functions
|
int
peer_allowas_in_set (struct peer *peer, afi_t afi, safi_t safi, int allow_num)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (allow_num < 1 || allow_num > 10)
return BGP_ERR_INVALID_VALUE;
if (peer->allowas_in[afi][safi] != allow_num)
{
peer->allowas_in[afi][safi] = allow_num;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN);
peer_change_action (peer, afi, safi, peer_change_reset_in);
}
|
functions
|
int
peer_allowas_in_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
peer->allowas_in[afi][safi] = 0;
peer_af_flag_unset (peer, afi, safi, PEER_FLAG_ALLOWAS_IN);
}
|
functions
|
int
peer_local_as_set (struct peer *peer, as_t as, int no_prepend)
{
struct bgp *bgp = peer->bgp;
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_sort (peer) != BGP_PEER_EBGP
&& peer_sort (peer) != BGP_PEER_INTERNAL)
return BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP;
if (bgp->as == as)
return BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (peer->change_local_as == as &&
((CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) && no_prepend)
|| (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) && ! no_prepend)))
return 0;
peer->change_local_as = as;
if (no_prepend)
SET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
else
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
|
functions
|
int
peer_local_as_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (! peer->change_local_as)
return 0;
peer->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
|
functions
|
int
peer_password_set (struct peer *peer, const char *password)
{
struct listnode *nn, *nnode;
int len = password ? strlen(password) : 0;
int ret = BGP_SUCCESS;
if ((len < PEER_PASSWORD_MINLEN) || (len > PEER_PASSWORD_MAXLEN))
return BGP_ERR_INVALID_VALUE;
if (peer->password && strcmp (peer->password, password) == 0
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
if (peer->password)
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, password);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
return (bgp_md5_set (peer) >= 0) ? BGP_SUCCESS : BGP_ERR_TCPSIG_FAILED;
}
|
functions
|
int
peer_password_unset (struct peer *peer)
{
struct listnode *nn, *nnode;
if (!peer->password
&& !CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
if (!CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer_group_active (peer)
&& peer->group->conf->password
&& strcmp (peer->group->conf->password, peer->password) == 0)
return BGP_ERR_PEER_GROUP_HAS_THE_FLAG;
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
if (peer->password)
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
bgp_md5_set (peer);
return 0;
}
|
functions
|
int
peer_distribute_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->plist[direct].name)
return BGP_ERR_PEER_FILTER_CONFLICT;
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = strdup (name);
filter->dlist[direct].alist = access_list_lookup (afi, name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = strdup (name);
filter->dlist[direct].alist = access_list_lookup (afi, name);
}
|
functions
|
int
peer_distribute_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->dlist[direct].name)
{
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = strdup (gfilter->dlist[direct].name);
filter->dlist[direct].alist = gfilter->dlist[direct].alist;
return 0;
}
|
functions
|
void
peer_distribute_update (struct access_list *access)
{
afi_t afi;
safi_t safi;
int direct;
struct listnode *mnode, *mnnode;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->dlist[direct].name)
filter->dlist[direct].alist =
access_list_lookup (afi, filter->dlist[direct].name);
else
filter->dlist[direct].alist = NULL;
}
|
functions
|
int
peer_prefix_list_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->dlist[direct].name)
return BGP_ERR_PEER_FILTER_CONFLICT;
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = strdup (name);
filter->plist[direct].plist = prefix_list_lookup (afi, name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = strdup (name);
filter->plist[direct].plist = prefix_list_lookup (afi, name);
}
|
functions
|
int
peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->plist[direct].name)
{
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = strdup (gfilter->plist[direct].name);
filter->plist[direct].plist = gfilter->plist[direct].plist;
return 0;
}
|
functions
|
void
peer_prefix_list_update (struct prefix_list *plist)
{
struct listnode *mnode, *mnnode;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
afi_t afi;
safi_t safi;
int direct;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->plist[direct].name)
filter->plist[direct].plist =
prefix_list_lookup (afi, filter->plist[direct].name);
else
filter->plist[direct].plist = NULL;
}
|
functions
|
int
peer_aslist_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = strdup (name);
filter->aslist[direct].aslist = as_list_lookup (name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = strdup (name);
filter->aslist[direct].aslist = as_list_lookup (name);
}
|
functions
|
int
peer_aslist_unset (struct peer *peer,afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->aslist[direct].name)
{
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = strdup (gfilter->aslist[direct].name);
filter->aslist[direct].aslist = gfilter->aslist[direct].aslist;
return 0;
}
|
functions
|
void
peer_aslist_update (void)
{
afi_t afi;
safi_t safi;
int direct;
struct listnode *mnode, *mnnode;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->aslist[direct].name)
filter->aslist[direct].aslist =
as_list_lookup (filter->aslist[direct].name);
else
filter->aslist[direct].aslist = NULL;
}
|
functions
|
int
peer_route_map_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != RMAP_IN && direct != RMAP_OUT &&
direct != RMAP_IMPORT && direct != RMAP_EXPORT)
return BGP_ERR_INVALID_VALUE;
if ( (direct == RMAP_OUT || direct == RMAP_IMPORT)
&& peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = strdup (name);
filter->map[direct].map = route_map_lookup_by_name (name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = strdup (name);
filter->map[direct].map = route_map_lookup_by_name (name);
}
|
functions
|
int
peer_route_map_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != RMAP_IN && direct != RMAP_OUT &&
direct != RMAP_IMPORT && direct != RMAP_EXPORT)
return BGP_ERR_INVALID_VALUE;
if ( (direct == RMAP_OUT || direct == RMAP_IMPORT)
&& peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->map[direct].name)
{
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = strdup (gfilter->map[direct].name);
filter->map[direct].map = gfilter->map[direct].map;
return 0;
}
|
functions
|
int
peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = strdup (name);
filter->usmap.map = route_map_lookup_by_name (name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = strdup (name);
filter->usmap.map = route_map_lookup_by_name (name);
}
|
functions
|
int
peer_unsuppress_map_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = NULL;
filter->usmap.map = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = NULL;
filter->usmap.map = NULL;
}
|
functions
|
int
peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi,
u_int32_t max, u_char threshold,
int warning, u_int16_t restart)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
peer->pmax[afi][safi] = max;
peer->pmax_threshold[afi][safi] = threshold;
peer->pmax_restart[afi][safi] = restart;
if (warning)
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
peer->pmax[afi][safi] = max;
peer->pmax_threshold[afi][safi] = threshold;
peer->pmax_restart[afi][safi] = restart;
if (warning)
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
}
|
functions
|
int
peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* apply peer-group config */
if (peer->af_group[afi][safi])
{
if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi],
PEER_FLAG_MAX_PREFIX))
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi],
PEER_FLAG_MAX_PREFIX_WARNING))
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
peer->pmax[afi][safi] = peer->group->conf->pmax[afi][safi];
peer->pmax_threshold[afi][safi] = peer->group->conf->pmax_threshold[afi][safi];
peer->pmax_restart[afi][safi] = peer->group->conf->pmax_restart[afi][safi];
return 0;
}
|
functions
|
int
peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops)
{
struct peer_group *group;
struct listnode *node, *nnode;
struct peer *peer1;
int ret;
zlog_debug ("peer_ttl_security_hops_set: set gtsm_hops to %d for %s", gtsm_hops, peer->host);
if (peer_sort (peer) == BGP_PEER_IBGP)
return BGP_ERR_NO_IBGP_WITH_TTLHACK;
/* We cannot configure ttl-security hops when ebgp-multihop is already
set. For non peer-groups, the check is simple. For peer-groups, it's
slightly messy, because we need to check both the peer-group structure
and all peer-group members for any trace of ebgp-multihop configuration
before actually applying the ttl-security rules. Cisco really made a
mess of this configuration parameter, and OpenBGPD got it right.
*/
if (peer->gtsm_hops == 0) {
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
if (group->conf->ttl != 1)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1))
{
if (peer_sort (peer1) == BGP_PEER_IBGP)
continue;
if (peer1->ttl != 1)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
|
functions
|
else if (peer->status < Established)
{
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s Min-ttl changed", peer->host);
BGP_EVENT_ADD (peer, BGP_Stop);
}
|
functions
|
int
peer_ttl_security_hops_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
struct peer *opeer;
zlog_debug ("peer_ttl_security_hops_unset: set gtsm_hops to zero for %s", peer->host);
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
/* if a peer-group member, then reset to peer-group default rather than 0 */
if (peer_group_active (peer))
peer->gtsm_hops = peer->group->conf->gtsm_hops;
else
peer->gtsm_hops = 0;
opeer = peer;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP)
sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0);
}
|
functions
|
int
peer_clear (struct peer *peer)
{
if (! CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
{
UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
if (peer->t_pmax_restart)
{
BGP_TIMER_OFF (peer->t_pmax_restart);
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s Maximum-prefix restart timer canceled",
peer->host);
}
|
functions
|
int
peer_clear_soft (struct peer *peer, afi_t afi, safi_t safi,
enum bgp_clear_type stype)
{
if (peer->status != Established)
return 0;
if (! peer->afc[afi][safi])
return BGP_ERR_AF_UNCONFIGURED;
if (stype == BGP_CLEAR_SOFT_RSCLIENT)
{
if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
return 0;
bgp_check_local_routes_rsclient (peer, afi, safi);
bgp_soft_reconfig_rsclient (peer, afi, safi);
}
|
functions
|
void
bgp_config_write_filter (struct vty *vty, struct peer *peer,
afi_t afi, safi_t safi)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter = NULL;
char *addr;
int in = FILTER_IN;
int out = FILTER_OUT;
addr = peer->host;
filter = &peer->filter[afi][safi];
if (peer->af_group[afi][safi])
gfilter = &peer->group->conf->filter[afi][safi];
/* distribute-list. */
if (filter->dlist[in].name)
if (! gfilter || ! gfilter->dlist[in].name
|| strcmp (filter->dlist[in].name, gfilter->dlist[in].name) != 0)
vty_out (vty, " neighbor %s distribute-list %s in%s", addr,
filter->dlist[in].name, VTY_NEWLINE);
if (filter->dlist[out].name && ! gfilter)
vty_out (vty, " neighbor %s distribute-list %s out%s", addr,
filter->dlist[out].name, VTY_NEWLINE);
/* prefix-list. */
if (filter->plist[in].name)
if (! gfilter || ! gfilter->plist[in].name
|| strcmp (filter->plist[in].name, gfilter->plist[in].name) != 0)
vty_out (vty, " neighbor %s prefix-list %s in%s", addr,
filter->plist[in].name, VTY_NEWLINE);
if (filter->plist[out].name && ! gfilter)
vty_out (vty, " neighbor %s prefix-list %s out%s", addr,
filter->plist[out].name, VTY_NEWLINE);
/* route-map. */
if (filter->map[RMAP_IN].name)
if (! gfilter || ! gfilter->map[RMAP_IN].name
|| strcmp (filter->map[RMAP_IN].name, gfilter->map[RMAP_IN].name) != 0)
vty_out (vty, " neighbor %s route-map %s in%s", addr,
filter->map[RMAP_IN].name, VTY_NEWLINE);
if (filter->map[RMAP_OUT].name && ! gfilter)
vty_out (vty, " neighbor %s route-map %s out%s", addr,
filter->map[RMAP_OUT].name, VTY_NEWLINE);
if (filter->map[RMAP_IMPORT].name && ! gfilter)
vty_out (vty, " neighbor %s route-map %s import%s", addr,
filter->map[RMAP_IMPORT].name, VTY_NEWLINE);
if (filter->map[RMAP_EXPORT].name)
if (! gfilter || ! gfilter->map[RMAP_EXPORT].name
|| strcmp (filter->map[RMAP_EXPORT].name,
gfilter->map[RMAP_EXPORT].name) != 0)
vty_out (vty, " neighbor %s route-map %s export%s", addr,
filter->map[RMAP_EXPORT].name, VTY_NEWLINE);
/* unsuppress-map */
if (filter->usmap.name && ! gfilter)
vty_out (vty, " neighbor %s unsuppress-map %s%s", addr,
filter->usmap.name, VTY_NEWLINE);
/* filter-list. */
if (filter->aslist[in].name)
if (! gfilter || ! gfilter->aslist[in].name
|| strcmp (filter->aslist[in].name, gfilter->aslist[in].name) != 0)
vty_out (vty, " neighbor %s filter-list %s in%s", addr,
filter->aslist[in].name, VTY_NEWLINE);
if (filter->aslist[out].name && ! gfilter)
vty_out (vty, " neighbor %s filter-list %s out%s", addr,
filter->aslist[out].name, VTY_NEWLINE);
}
|
functions
|
void
bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
struct peer *peer, afi_t afi, safi_t safi)
{
struct peer *g_peer = NULL;
char buf[SU_ADDRSTRLEN];
char *addr;
addr = peer->host;
if (peer_group_active (peer))
g_peer = peer->group->conf;
/************************************
****** Global to the neighbor ******
************************************/
if (afi == AFI_IP && safi == SAFI_UNICAST)
{
/* remote-as. */
if (! peer_group_active (peer))
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
vty_out (vty, " neighbor %s peer-group%s", addr,
VTY_NEWLINE);
if (peer->as)
vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as,
VTY_NEWLINE);
}
|
functions
|
void
bgp_config_write_family_header (struct vty *vty, afi_t afi, safi_t safi,
int *write)
{
if (*write)
return;
if (afi == AFI_IP && safi == SAFI_UNICAST)
return;
vty_out (vty, "!%s address-family ", VTY_NEWLINE);
if (afi == AFI_IP)
{
if (safi == SAFI_MULTICAST)
vty_out (vty, "ipv4 multicast");
else if (safi == SAFI_MPLS_VPN)
vty_out (vty, "vpnv4 unicast");
}
|
functions
|
else if (afi == AFI_IP6)
{
vty_out (vty, "ipv6");
if (safi == SAFI_MULTICAST)
vty_out (vty, " multicast");
}
|
functions
|
int
bgp_config_write_family (struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi)
{
int write = 0;
struct peer *peer;
struct peer_group *group;
struct listnode *node, *nnode;
bgp_config_write_network (vty, bgp, afi, safi, &write);
bgp_config_write_redistribute (vty, bgp, afi, safi, &write);
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (group->conf->afc[afi][safi])
{
bgp_config_write_family_header (vty, afi, safi, &write);
bgp_config_write_peer (vty, bgp, group->conf, afi, safi);
}
|
functions
|
int
bgp_config_write (struct vty *vty)
{
int write = 0;
struct bgp *bgp;
struct peer_group *group;
struct peer *peer;
struct listnode *node, *nnode;
struct listnode *mnode, *mnnode;
/* BGP Multiple instance. */
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
{
vty_out (vty, "bgp multiple-instance%s", VTY_NEWLINE);
write++;
}
|
functions
|
void
bgp_master_init (void)
{
memset (&bgp_master, 0, sizeof (struct bgp_master));
bm = &bgp_master;
bm->bgp = list_new ();
bm->listen_sockets = list_new ();
bm->port = BGP_PORT_DEFAULT;
bm->master = thread_master_create ();
bm->start_time = bgp_clock ();
}
|
functions
|
void
bgp_init (void)
{
/* BGP VTY commands installation. */
bgp_vty_init ();
/* Init kroute. */
bgp_kroute_init ();
/* BGP inits. */
bgp_attr_init ();
bgp_debug_init ();
bgp_dump_init ();
bgp_route_init ();
bgp_route_map_init ();
bgp_scan_init ();
bgp_mplsvpn_init ();
/* Access list initialize. */
access_list_init ();
access_list_add_hook (peer_distribute_update);
access_list_delete_hook (peer_distribute_update);
/* Filter list initialize. */
bgp_filter_init ();
as_list_add_hook (peer_aslist_update);
as_list_delete_hook (peer_aslist_update);
/* Prefix list initialize.*/
prefix_list_init ();
prefix_list_add_hook (peer_prefix_list_update);
prefix_list_delete_hook (peer_prefix_list_update);
/* Community list initialize. */
bgp_clist = community_list_init ();
#ifdef HAVE_SNMP
bgp_snmp_init ();
#endif /* HAVE_SNMP */
}
|
functions
|
void
bgp_terminate (void)
{
struct bgp *bgp;
struct peer *peer;
struct listnode *node, *nnode;
struct listnode *mnode, *mnnode;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
bgp_cleanup_routes ();
if (bm->process_main_queue)
{
work_queue_free (bm->process_main_queue);
bm->process_main_queue = NULL;
}
|
includes
|
#include <linux/module.h>
|
includes
|
#include <linux/init.h>
|
includes
|
#include <linux/skbuff.h>
|
includes
|
#include <linux/netfilter/x_tables.h>
|
includes
|
#include <linux/netfilter/xt_NFLOG.h>
|
includes
|
#include <net/netfilter/nf_log.h>
|
includes
|
#include <net/netfilter/nfnetlink_log.h>
|
functions
|
int
nflog_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
const struct xt_nflog_info *info = par->targinfo;
struct nf_loginfo li;
li.type = NF_LOG_TYPE_ULOG;
li.u.ulog.copy_len = info->len;
li.u.ulog.group = info->group;
li.u.ulog.qthreshold = info->threshold;
nfulnl_log_packet(par->family, par->hooknum, skb, par->in,
par->out, &li, info->prefix);
return XT_CONTINUE;
}
|
functions
|
bool nflog_tg_check(const struct xt_tgchk_param *par)
{
const struct xt_nflog_info *info = par->targinfo;
if (info->flags & ~XT_NFLOG_MASK)
return false;
if (info->prefix[sizeof(info->prefix) - 1] != '\0')
return false;
return true;
}
|
functions
|
__init nflog_tg_init(void)
{
return xt_register_target(&nflog_tg_reg);
}
|
functions
|
__exit nflog_tg_exit(void)
{
xt_unregister_target(&nflog_tg_reg);
}
|
includes
|
#include <linux/module.h>
|
includes
|
#include <linux/kernel.h>
|
includes
|
#include <linux/stddef.h>
|
includes
|
#include <linux/ioport.h>
|
includes
|
#include <linux/delay.h>
|
includes
|
#include <linux/utsname.h>
|
includes
|
#include <linux/initrd.h>
|
includes
|
#include <linux/console.h>
|
includes
|
#include <linux/bootmem.h>
|
includes
|
#include <linux/seq_file.h>
|
includes
|
#include <linux/screen_info.h>
|
includes
|
#include <linux/init.h>
|
includes
|
#include <linux/kexec.h>
|
includes
|
#include <linux/of_fdt.h>
|
includes
|
#include <linux/crash_dump.h>
|
includes
|
#include <linux/root_dev.h>
|
includes
|
#include <linux/cpu.h>
|
includes
|
#include <linux/interrupt.h>
|
includes
|
#include <linux/smp.h>
|
includes
|
#include <linux/fs.h>
|
includes
|
#include <linux/proc_fs.h>
|
includes
|
#include <linux/memblock.h>
|
includes
|
#include <asm/unified.h>
|
includes
|
#include <asm/cpu.h>
|
includes
|
#include <asm/cputype.h>
|
includes
|
#include <asm/elf.h>
|
includes
|
#include <asm/procinfo.h>
|
includes
|
#include <asm/sections.h>
|
includes
|
#include <asm/setup.h>
|
includes
|
#include <asm/smp_plat.h>
|
includes
|
#include <asm/mach-types.h>
|
includes
|
#include <asm/cacheflush.h>
|
includes
|
#include <asm/cachetype.h>
|
includes
|
#include <asm/tlbflush.h>
|
includes
|
#include <asm/prom.h>
|
includes
|
#include <asm/mach/arch.h>
|
includes
|
#include <asm/mach/irq.h>
|
includes
|
#include <asm/mach/time.h>
|
includes
|
#include <asm/traps.h>
|
includes
|
#include <asm/unwind.h>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.