Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Fix some bugs of set tcp-mss on listen socket. #14449

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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*
forsunwell marked this conversation as resolved.
Show resolved Hide resolved
*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)
forsunwell marked this conversation as resolved.
Show resolved Hide resolved
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)) {
forsunwell marked this conversation as resolved.
Show resolved Hide resolved
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)) {
forsunwell marked this conversation as resolved.
Show resolved Hide resolved
UNSET_FLAG(p->flags, PEER_FLAG_TCP_MSS);
p->tcp_mss = 0;
}
}

bgp_tcp_mss_set(peer);
}

Expand Down