Skip to content

Commit

Permalink
bgpd: Fix some bugs of set tcp-mss on listen socket.
Browse files Browse the repository at this point in the history
    1.Tcp-mss not just for bgp neighbor, but also for bgp neighbor group.
    2.Set tcp-mss for listhen socket even no neighbor config passive mode.
    3.Config tcp-mss on neighbor group sync to all the neighbor in that group.
  • Loading branch information
forsunwell committed Sep 20, 2023
1 parent 7a80a23 commit ce9deab
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ refix
/test-suite.log
pceplib/test/*.log
pceplib/test/*.trs
*.si4project*
*gitignore*
18 changes: 17 additions & 1 deletion bgpd/bgp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ int bgp_tcp_mss_set(struct peer *peer)
struct bgp_listener *listener;
uint32_t min_mss = 0;
struct peer *p;
struct peer_group *group;

for (ALL_LIST_ELEMENTS_RO(peer->bgp->peer, node, p)) {
if (!CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS))
Expand All @@ -355,6 +356,21 @@ int bgp_tcp_mss_set(struct peer *peer)
min_mss = MIN(min_mss, p->tcp_mss);
}

for (ALL_LIST_ELEMENTS_RO(peer->bgp->group, node, group)) {
p = group->conf;
if (!CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS))
continue;

if (!p->tcp_mss)
continue;

if (!min_mss)
min_mss = p->tcp_mss;

min_mss = MIN(min_mss, p->tcp_mss);
}


frr_with_privs(&bgpd_privs) {
for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) {
if (listener->su.sa.sa_family !=
Expand All @@ -371,7 +387,7 @@ int bgp_tcp_mss_set(struct peer *peer)
* one peer that is in passive mode. Otherwise, TCP MSS
* is set per socket via bgp_connect().
*/
if (CHECK_FLAG(peer->flags, PEER_FLAG_PASSIVE))
if (min_mss != 0)
sockopt_tcp_mss_set(listener->fd, min_mss);

break;
Expand Down
22 changes: 22 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -5777,8 +5777,19 @@ void peer_port_unset(struct peer *peer)
*/
void peer_tcp_mss_set(struct peer *peer, uint32_t tcp_mss)
{
struct listnode *node;
struct peer *p;

peer->tcp_mss = tcp_mss;
SET_FLAG(peer->flags, PEER_FLAG_TCP_MSS);

if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
for (ALL_LIST_ELEMENTS_RO(peer->group->peer, node, p)) {
p->tcp_mss = tcp_mss;
SET_FLAG(p->flags, PEER_FLAG_TCP_MSS);
}
}

bgp_tcp_mss_set(peer);
}

Expand All @@ -5788,8 +5799,19 @@ void peer_tcp_mss_set(struct peer *peer, uint32_t tcp_mss)
*/
void peer_tcp_mss_unset(struct peer *peer)
{
struct listnode *node;
struct peer *p;

UNSET_FLAG(peer->flags, PEER_FLAG_TCP_MSS);
peer->tcp_mss = 0;

if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
for (ALL_LIST_ELEMENTS_RO(peer->group->peer, node, p)) {
UNSET_FLAG(p->flags, PEER_FLAG_TCP_MSS);
p->tcp_mss = 0;
}
}

bgp_tcp_mss_set(peer);
}

Expand Down

0 comments on commit ce9deab

Please sign in to comment.