diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-09-30 09:42:25 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-09-30 09:42:25 +0000 |
commit | 2dc9e7f95ab0865abe81409b728afede64306b39 (patch) | |
tree | 7b4f673ca7a5535ed371069933c8c5d810eef4f6 /usr.sbin/bgpd | |
parent | a393f0223151ca3781c80612e64f5112b43c3181 (diff) |
In bgpd_rtr_connect() do the setsockopt dance for IP_TOS and TCP_NODELAY
before calling connect(). This way it happens for sure and on top the TOS
is already set on the initial SYN.
OK tb@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index bb0e19d01a8..572551ce4d8 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.267 2024/09/04 15:06:36 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.268 2024/09/30 09:42:24 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1381,6 +1381,29 @@ bgpd_rtr_connect(struct rtr_config *r) return; } + switch (r->remote_addr.aid) { + case AID_INET: + if (setsockopt(ce->fd, IPPROTO_IP, IP_TOS, &pre, sizeof(pre)) == + -1) { + log_warn("rtr %s: setsockopt IP_TOS", r->descr); + return; + } + break; + case AID_INET6: + if (setsockopt(ce->fd, IPPROTO_IPV6, IPV6_TCLASS, &pre, + sizeof(pre)) == -1) { + log_warn("rtr %s: setsockopt IP_TOS", r->descr); + return; + } + break; + } + + if (setsockopt(ce->fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, + sizeof(nodelay)) == -1) { + log_warn("rtr %s: setsockopt TCP_NODELAY", r->descr); + return; + } + if ((sa = addr2sa(&r->local_addr, 0, &len)) != NULL) { if (bind(ce->fd, sa, len) == -1) { log_warn("rtr %s: bind to %s", r->descr, @@ -1405,29 +1428,6 @@ bgpd_rtr_connect(struct rtr_config *r) return; } - switch (r->remote_addr.aid) { - case AID_INET: - if (setsockopt(ce->fd, IPPROTO_IP, IP_TOS, &pre, sizeof(pre)) == - -1) { - log_warn("rtr %s: setsockopt IP_TOS", r->descr); - return; - } - break; - case AID_INET6: - if (setsockopt(ce->fd, IPPROTO_IPV6, IPV6_TCLASS, &pre, - sizeof(pre)) == -1) { - log_warn("rtr %s: setsockopt IP_TOS", r->descr); - return; - } - break; - } - - if (setsockopt(ce->fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, - sizeof(nodelay)) == -1) { - log_warn("rtr %s: setsockopt TCP_NODELAY", r->descr); - return; - } - imsg_compose(ibuf_rtr, IMSG_SOCKET_CONN, ce->id, 0, ce->fd, NULL, 0); free(ce); } |