mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 11:01:48 +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 update_subgroup *subgrp;
|
||||
|
||||
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
||||
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) {
|
||||
paf = peer_af_find(peer, afi, safi);
|
||||
if (!paf)
|
||||
continue;
|
||||
subgrp = paf->subgroup;
|
||||
if (!subgrp)
|
||||
continue;
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
paf = peer_af_find(peer, afi, safi);
|
||||
if (!paf)
|
||||
continue;
|
||||
subgrp = paf->subgroup;
|
||||
if (!subgrp)
|
||||
continue;
|
||||
|
||||
next_pkt = paf->next_pkt_to_send;
|
||||
if (next_pkt && next_pkt->buffer) {
|
||||
next_pkt = paf->next_pkt_to_send;
|
||||
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_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_generate_updgrp_packets, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,77 +390,67 @@ int bgp_generate_updgrp_packets(struct thread *thread)
|
||||
|
||||
do {
|
||||
s = NULL;
|
||||
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
||||
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) {
|
||||
paf = peer_af_find(peer, afi, safi);
|
||||
if (!paf || !PAF_SUBGRP(paf))
|
||||
continue;
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
paf = peer_af_find(peer, afi, safi);
|
||||
if (!paf || !PAF_SUBGRP(paf))
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we still don't have a packet to send to
|
||||
* the peer, then try to find out out if we
|
||||
* have to send eor or if not, skip to the next
|
||||
* AFI, SAFI. Don't send the EOR prematurely...
|
||||
* 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]
|
||||
/*
|
||||
* If we still don't have a packet to send to the peer,
|
||||
* then try to find out out if we have to send eor or
|
||||
* if not, skip to the next AFI, SAFI. Don't send the
|
||||
* EOR prematurely; 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],
|
||||
PEER_STATUS_EOR_SEND);
|
||||
PEER_STATUS_EOR_SEND);
|
||||
|
||||
if ((s = bgp_update_packet_eor(
|
||||
peer, afi,
|
||||
safi))) {
|
||||
bgp_packet_add(
|
||||
peer,
|
||||
s);
|
||||
bgp_writes_on(
|
||||
peer);
|
||||
}
|
||||
if ((s = bgp_update_packet_eor(
|
||||
peer, afi,
|
||||
safi))) {
|
||||
bgp_packet_add(peer, s);
|
||||
bgp_writes_on(peer);
|
||||
}
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
} while (s && (++generated < wpq));
|
||||
|
||||
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