mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 08:38:42 +00:00
OSPF: Minor refactoring of packet sending code
Common behavior for LSupd and delayed LSack moved to ospf_send_to_iface() and other minor changes.
This commit is contained in:
parent
255722e0fc
commit
1647923bd8
@ -111,20 +111,12 @@ ospf_send_lsack_(struct ospf_proto *p, struct ospf_neighbor *n, int queue)
|
||||
{
|
||||
OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent to nbr %R on %s", n->rid, ifa->ifname);
|
||||
ospf_send_to(ifa, n->ip);
|
||||
return;
|
||||
}
|
||||
|
||||
OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent via %s", ifa->ifname);
|
||||
|
||||
if (ifa->type == OSPF_IT_BCAST)
|
||||
{
|
||||
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
|
||||
ospf_send_to_all(ifa);
|
||||
else
|
||||
ospf_send_to_des(ifa);
|
||||
}
|
||||
else
|
||||
ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
|
||||
{
|
||||
OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent via %s", ifa->ifname);
|
||||
ospf_send_to_iface(ifa);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -398,15 +398,7 @@ ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_list, uint ls
|
||||
OSPF_PACKET(ospf_dump_lsupd, ospf_tx_buffer(ifa),
|
||||
"LSUPD packet flooded via %s", ifa->ifname);
|
||||
|
||||
if (ifa->type == OSPF_IT_BCAST)
|
||||
{
|
||||
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
|
||||
ospf_send_to_all(ifa);
|
||||
else
|
||||
ospf_send_to_des(ifa);
|
||||
}
|
||||
else
|
||||
ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
|
||||
ospf_send_to_iface(ifa);
|
||||
}
|
||||
|
||||
return i;
|
||||
|
@ -1056,22 +1056,13 @@ int ospf_rx_hook(sock * sk, uint size);
|
||||
void ospf_err_hook(sock * sk, int err);
|
||||
void ospf_verr_hook(sock *sk, int err);
|
||||
void ospf_send_to(struct ospf_iface *ifa, ip_addr ip);
|
||||
void ospf_send_to_agt(struct ospf_iface *ifa, u8 state);
|
||||
void ospf_send_to_bdr(struct ospf_iface *ifa);
|
||||
|
||||
static inline uint ospf_pkt_maxsize(struct ospf_iface *ifa)
|
||||
{ return ifa->tx_length - ifa->tx_hdrlen; }
|
||||
void ospf_send_to_iface(struct ospf_iface *ifa);
|
||||
|
||||
static inline void ospf_send_to_all(struct ospf_iface *ifa)
|
||||
{ ospf_send_to(ifa, ifa->all_routers); }
|
||||
|
||||
static inline void ospf_send_to_des(struct ospf_iface *ifa)
|
||||
{
|
||||
if (ipa_nonzero(ifa->des_routers))
|
||||
ospf_send_to(ifa, ifa->des_routers);
|
||||
else
|
||||
ospf_send_to_bdr(ifa);
|
||||
}
|
||||
static inline uint ospf_pkt_maxsize(struct ospf_iface *ifa)
|
||||
{ return ifa->tx_length - ifa->tx_hdrlen; }
|
||||
|
||||
#ifndef PARSER
|
||||
#define DROP(DSC,VAL) do { err_dsc = DSC; err_val = VAL; goto drop; } while(0)
|
||||
|
@ -664,21 +664,44 @@ ospf_send_to(struct ospf_iface *ifa, ip_addr dst)
|
||||
log(L_WARN "OSPF: TX queue full on %s", ifa->ifname);
|
||||
}
|
||||
|
||||
void
|
||||
ospf_send_to_agt(struct ospf_iface *ifa, u8 state)
|
||||
static void
|
||||
ospf_send_to_designated(struct ospf_iface *ifa)
|
||||
{
|
||||
/* In case of real-broadcast mode */
|
||||
if (ipa_zero(ifa->des_routers))
|
||||
{
|
||||
if (ipa_nonzero2(ifa->drip))
|
||||
ospf_send_to(ifa, ifa->drip);
|
||||
|
||||
if (ipa_nonzero2(ifa->bdrip))
|
||||
ospf_send_to(ifa, ifa->bdrip);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ospf_send_to(ifa, ifa->des_routers);
|
||||
}
|
||||
|
||||
static void
|
||||
ospf_send_to_adjacent(struct ospf_iface *ifa)
|
||||
{
|
||||
struct ospf_neighbor *n;
|
||||
|
||||
WALK_LIST(n, ifa->neigh_list)
|
||||
if (n->state >= state)
|
||||
if (n->state >= NEIGHBOR_EXCHANGE)
|
||||
ospf_send_to(ifa, n->ip);
|
||||
}
|
||||
|
||||
void
|
||||
ospf_send_to_bdr(struct ospf_iface *ifa)
|
||||
ospf_send_to_iface(struct ospf_iface *ifa)
|
||||
{
|
||||
if (ipa_nonzero2(ifa->drip))
|
||||
ospf_send_to(ifa, ifa->drip);
|
||||
if (ipa_nonzero2(ifa->bdrip))
|
||||
ospf_send_to(ifa, ifa->bdrip);
|
||||
if (ifa->type == OSPF_IT_BCAST)
|
||||
{
|
||||
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
|
||||
ospf_send_to_all(ifa);
|
||||
else
|
||||
ospf_send_to_designated(ifa);
|
||||
}
|
||||
else /* Non-broadcast */
|
||||
ospf_send_to_adjacent(ifa);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user