mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 23:29:36 +00:00
bgpd: use FOREACH_AFI_SAFI()
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
4961a5a2eb
commit
c58b0f46dd
@ -315,48 +315,45 @@ static void bgp_write_proceed_actions(struct peer *peer)
|
|||||||
struct bpacket *next_pkt;
|
struct bpacket *next_pkt;
|
||||||
struct update_subgroup *subgrp;
|
struct update_subgroup *subgrp;
|
||||||
|
|
||||||
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
FOREACH_AFI_SAFI (afi, safi) {
|
||||||
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) {
|
paf = peer_af_find(peer, afi, safi);
|
||||||
paf = peer_af_find(peer, afi, safi);
|
if (!paf)
|
||||||
if (!paf)
|
continue;
|
||||||
continue;
|
subgrp = paf->subgroup;
|
||||||
subgrp = paf->subgroup;
|
if (!subgrp)
|
||||||
if (!subgrp)
|
continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
next_pkt = paf->next_pkt_to_send;
|
next_pkt = paf->next_pkt_to_send;
|
||||||
if (next_pkt && next_pkt->buffer) {
|
if (next_pkt && next_pkt->buffer) {
|
||||||
|
BGP_TIMER_ON(peer->t_generate_updgrp_packets,
|
||||||
|
bgp_generate_updgrp_packets, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No packets readily available for AFI/SAFI, are there
|
||||||
|
* subgroup packets
|
||||||
|
* that need to be generated? */
|
||||||
|
if (bpacket_queue_is_full(SUBGRP_INST(subgrp),
|
||||||
|
SUBGRP_PKTQ(subgrp))
|
||||||
|
|| subgroup_packets_to_build(subgrp)) {
|
||||||
|
BGP_TIMER_ON(peer->t_generate_updgrp_packets,
|
||||||
|
bgp_generate_updgrp_packets, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No packets to send, see if EOR is pending */
|
||||||
|
if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
|
||||||
|
if (!subgrp->t_coalesce && peer->afc_nego[afi][safi]
|
||||||
|
&& peer->synctime
|
||||||
|
&& !CHECK_FLAG(peer->af_sflags[afi][safi],
|
||||||
|
PEER_STATUS_EOR_SEND)
|
||||||
|
&& safi != SAFI_MPLS_VPN) {
|
||||||
BGP_TIMER_ON(peer->t_generate_updgrp_packets,
|
BGP_TIMER_ON(peer->t_generate_updgrp_packets,
|
||||||
bgp_generate_updgrp_packets, 0);
|
bgp_generate_updgrp_packets, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No packets readily available for AFI/SAFI, are there
|
|
||||||
* subgroup packets
|
|
||||||
* that need to be generated? */
|
|
||||||
if (bpacket_queue_is_full(SUBGRP_INST(subgrp),
|
|
||||||
SUBGRP_PKTQ(subgrp))
|
|
||||||
|| subgroup_packets_to_build(subgrp)) {
|
|
||||||
BGP_TIMER_ON(peer->t_generate_updgrp_packets,
|
|
||||||
bgp_generate_updgrp_packets, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No packets to send, see if EOR is pending */
|
|
||||||
if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
|
|
||||||
if (!subgrp->t_coalesce
|
|
||||||
&& peer->afc_nego[afi][safi]
|
|
||||||
&& peer->synctime
|
|
||||||
&& !CHECK_FLAG(peer->af_sflags[afi][safi],
|
|
||||||
PEER_STATUS_EOR_SEND)
|
|
||||||
&& safi != SAFI_MPLS_VPN) {
|
|
||||||
BGP_TIMER_ON(
|
|
||||||
peer->t_generate_updgrp_packets,
|
|
||||||
bgp_generate_updgrp_packets, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -393,77 +390,67 @@ int bgp_generate_updgrp_packets(struct thread *thread)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
FOREACH_AFI_SAFI (afi, safi) {
|
||||||
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) {
|
paf = peer_af_find(peer, afi, safi);
|
||||||
paf = peer_af_find(peer, afi, safi);
|
if (!paf || !PAF_SUBGRP(paf))
|
||||||
if (!paf || !PAF_SUBGRP(paf))
|
continue;
|
||||||
continue;
|
next_pkt = paf->next_pkt_to_send;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to generate a packet for the peer if we are at
|
||||||
|
* the end of the list. Always try to push out
|
||||||
|
* WITHDRAWs first.
|
||||||
|
*/
|
||||||
|
if (!next_pkt || !next_pkt->buffer) {
|
||||||
|
next_pkt = subgroup_withdraw_packet(
|
||||||
|
PAF_SUBGRP(paf));
|
||||||
|
if (!next_pkt || !next_pkt->buffer)
|
||||||
|
subgroup_update_packet(PAF_SUBGRP(paf));
|
||||||
next_pkt = paf->next_pkt_to_send;
|
next_pkt = paf->next_pkt_to_send;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to generate a packet for the peer if we
|
* If we still don't have a packet to send to the peer,
|
||||||
* are at the end of the list. Always try to
|
* then try to find out out if we have to send eor or
|
||||||
* push out WITHDRAWs first.
|
* if not, skip to the next AFI, SAFI. Don't send the
|
||||||
*/
|
* EOR prematurely; if the subgroup's coalesce timer is
|
||||||
if (!next_pkt || !next_pkt->buffer) {
|
* running, the adjacency-out structure is not created
|
||||||
next_pkt = subgroup_withdraw_packet(
|
* yet.
|
||||||
PAF_SUBGRP(paf));
|
*/
|
||||||
if (!next_pkt || !next_pkt->buffer)
|
if (!next_pkt || !next_pkt->buffer) {
|
||||||
subgroup_update_packet(
|
if (CHECK_FLAG(peer->cap,
|
||||||
PAF_SUBGRP(paf));
|
PEER_CAP_RESTART_RCV)) {
|
||||||
next_pkt = paf->next_pkt_to_send;
|
if (!(PAF_SUBGRP(paf))->t_coalesce
|
||||||
}
|
&& peer->afc_nego[afi][safi]
|
||||||
|
&& peer->synctime
|
||||||
/*
|
&& !CHECK_FLAG(
|
||||||
* If we still don't have a packet to send to
|
peer->af_sflags[afi]
|
||||||
* the peer, then try to find out out if we
|
[safi],
|
||||||
* have to send eor or if not, skip to the next
|
PEER_STATUS_EOR_SEND)) {
|
||||||
* AFI, SAFI. Don't send the EOR prematurely...
|
SET_FLAG(peer->af_sflags[afi]
|
||||||
* if the subgroup's coalesce timer is running,
|
|
||||||
* the adjacency-out structure is not created
|
|
||||||
* yet.
|
|
||||||
*/
|
|
||||||
if (!next_pkt || !next_pkt->buffer) {
|
|
||||||
if (CHECK_FLAG(peer->cap,
|
|
||||||
PEER_CAP_RESTART_RCV)) {
|
|
||||||
if (!(PAF_SUBGRP(paf))
|
|
||||||
->t_coalesce
|
|
||||||
&& peer->afc_nego[afi][safi]
|
|
||||||
&& peer->synctime
|
|
||||||
&& !CHECK_FLAG(
|
|
||||||
peer->af_sflags
|
|
||||||
[afi]
|
|
||||||
[safi],
|
|
||||||
PEER_STATUS_EOR_SEND)) {
|
|
||||||
SET_FLAG(
|
|
||||||
peer->af_sflags
|
|
||||||
[afi]
|
|
||||||
[safi],
|
[safi],
|
||||||
PEER_STATUS_EOR_SEND);
|
PEER_STATUS_EOR_SEND);
|
||||||
|
|
||||||
if ((s = bgp_update_packet_eor(
|
if ((s = bgp_update_packet_eor(
|
||||||
peer, afi,
|
peer, afi,
|
||||||
safi))) {
|
safi))) {
|
||||||
bgp_packet_add(
|
bgp_packet_add(peer, s);
|
||||||
peer,
|
bgp_writes_on(peer);
|
||||||
s);
|
|
||||||
bgp_writes_on(
|
|
||||||
peer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
|
||||||
/* Found a packet template to send, overwrite
|
|
||||||
* packet with appropriate attributes from peer
|
|
||||||
* and advance peer */
|
|
||||||
s = bpacket_reformat_for_peer(next_pkt, paf);
|
|
||||||
bgp_packet_add(peer, s);
|
|
||||||
bgp_writes_on(peer);
|
|
||||||
bpacket_queue_advance_peer(paf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Found a packet template to send, overwrite
|
||||||
|
* packet with appropriate attributes from peer
|
||||||
|
* and advance peer */
|
||||||
|
s = bpacket_reformat_for_peer(next_pkt, paf);
|
||||||
|
bgp_packet_add(peer, s);
|
||||||
|
bgp_writes_on(peer);
|
||||||
|
bpacket_queue_advance_peer(paf);
|
||||||
|
}
|
||||||
} while (s && (++generated < wpq));
|
} while (s && (++generated < wpq));
|
||||||
|
|
||||||
bgp_write_proceed_actions(peer);
|
bgp_write_proceed_actions(peer);
|
||||||
|
92
ospfd/ospf_vty_clippy.c
Normal file
92
ospfd/ospf_vty_clippy.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* ospf_router_id => "ospf router-id A.B.C.D" */
|
||||||
|
DEFUN_CMD_FUNC_DECL(ospf_router_id)
|
||||||
|
#define funcdecl_ospf_router_id static int ospf_router_id_magic(\
|
||||||
|
const struct cmd_element *self __attribute__ ((unused)),\
|
||||||
|
struct vty *vty __attribute__ ((unused)),\
|
||||||
|
int argc __attribute__ ((unused)),\
|
||||||
|
struct cmd_token *argv[] __attribute__ ((unused)),\
|
||||||
|
struct in_addr router_id,\
|
||||||
|
const char * router_id_str __attribute__ ((unused)))
|
||||||
|
funcdecl_ospf_router_id;
|
||||||
|
DEFUN_CMD_FUNC_TEXT(ospf_router_id)
|
||||||
|
{
|
||||||
|
#if 1 /* anything to parse? */
|
||||||
|
int _i;
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
unsigned _fail = 0, _failcnt = 0;
|
||||||
|
#endif
|
||||||
|
struct in_addr router_id = { INADDR_ANY };
|
||||||
|
const char *router_id_str = NULL;
|
||||||
|
|
||||||
|
for (_i = 0; _i < argc; _i++) {
|
||||||
|
if (!argv[_i]->varname)
|
||||||
|
continue;
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
_fail = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!strcmp(argv[_i]->varname, "router_id")) {
|
||||||
|
router_id_str = argv[_i]->arg;
|
||||||
|
_fail = !inet_aton(argv[_i]->arg, &router_id);
|
||||||
|
}
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
if (_fail)
|
||||||
|
vty_out (vty, "%% invalid input for %s: %s\n",
|
||||||
|
argv[_i]->varname, argv[_i]->arg);
|
||||||
|
_failcnt += _fail;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
if (_failcnt)
|
||||||
|
return CMD_WARNING;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return ospf_router_id_magic(self, vty, argc, argv, router_id, router_id_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no_ospf_router_id => "no ospf router-id [A.B.C.D]" */
|
||||||
|
DEFUN_CMD_FUNC_DECL(no_ospf_router_id)
|
||||||
|
#define funcdecl_no_ospf_router_id static int no_ospf_router_id_magic(\
|
||||||
|
const struct cmd_element *self __attribute__ ((unused)),\
|
||||||
|
struct vty *vty __attribute__ ((unused)),\
|
||||||
|
int argc __attribute__ ((unused)),\
|
||||||
|
struct cmd_token *argv[] __attribute__ ((unused)),\
|
||||||
|
struct in_addr router_id,\
|
||||||
|
const char * router_id_str __attribute__ ((unused)))
|
||||||
|
funcdecl_no_ospf_router_id;
|
||||||
|
DEFUN_CMD_FUNC_TEXT(no_ospf_router_id)
|
||||||
|
{
|
||||||
|
#if 1 /* anything to parse? */
|
||||||
|
int _i;
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
unsigned _fail = 0, _failcnt = 0;
|
||||||
|
#endif
|
||||||
|
struct in_addr router_id = { INADDR_ANY };
|
||||||
|
const char *router_id_str = NULL;
|
||||||
|
|
||||||
|
for (_i = 0; _i < argc; _i++) {
|
||||||
|
if (!argv[_i]->varname)
|
||||||
|
continue;
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
_fail = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!strcmp(argv[_i]->varname, "router_id")) {
|
||||||
|
router_id_str = argv[_i]->arg;
|
||||||
|
_fail = !inet_aton(argv[_i]->arg, &router_id);
|
||||||
|
}
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
if (_fail)
|
||||||
|
vty_out (vty, "%% invalid input for %s: %s\n",
|
||||||
|
argv[_i]->varname, argv[_i]->arg);
|
||||||
|
_failcnt += _fail;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if 1 /* anything that can fail? */
|
||||||
|
if (_failcnt)
|
||||||
|
return CMD_WARNING;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return no_ospf_router_id_magic(self, vty, argc, argv, router_id, router_id_str);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user