diff options
| author | Richard Kümmel <R.Kuemmel@beckhoff.com> | 2023-12-15 11:49:45 +0000 |
|---|---|---|
| committer | Emmanuel Vadot <manu@FreeBSD.org> | 2024-01-02 06:49:12 +0000 |
| commit | 7df9da47e8f04267330e1baa751f07c0c4aaf2ac (patch) | |
| tree | 3ca30cfa5fbb7cccdfaa293dc3dce664fd372ae7 /sys/netinet/udp_usrreq.c | |
| parent | 78cd75393ec79565c63927bf200f06f839a1dc05 (diff) | |
Fix udp IPv4-mapped address
Do not use the cached route if the destination isn't the same.
This fix a problem where an UDP packet will be sent via the wrong route
and interface if a previous one was sent via them.
PR: 275774
Reviewed by: glebius, tuexen
Sponsored by: Beckhoff Automation GmbH & Co. KG
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
| -rw-r--r-- | sys/netinet/udp_usrreq.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index f7e0f7417818..affdb3b1f4c7 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1061,6 +1061,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, uint16_t cscov = 0; uint32_t flowid = 0; uint8_t flowtype = M_HASHTYPE_NONE; + bool use_cached_route; inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp_send: inp == NULL")); @@ -1097,9 +1098,8 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, * We will need network epoch in either case, to safely lookup into * pcb hash. */ - if (sin == NULL || - (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0) || - (flags & PRUS_IPV6) != 0) + use_cached_route = sin == NULL || (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0); + if (use_cached_route || (flags & PRUS_IPV6) != 0) INP_WLOCK(inp); else INP_RLOCK(inp); @@ -1450,7 +1450,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, else UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u); error = ip_output(m, inp->inp_options, - INP_WLOCKED(inp) ? &inp->inp_route : NULL, ipflags, + use_cached_route ? &inp->inp_route : NULL, ipflags, inp->inp_moptions, inp); INP_UNLOCK(inp); NET_EPOCH_EXIT(et); |
