git: 465942e8cc81 - main - raw ip: clear sin_port on bind(2)

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Sat, 12 Sep 2026 12:14:23 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=465942e8cc8160b21e1a3d5e45fa3ddbb852f6db

commit 465942e8cc8160b21e1a3d5e45fa3ddbb852f6db
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-09-12 12:12:36 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-09-12 12:12:36 +0000

    raw ip: clear sin_port on bind(2)
    
    Application may set sin_port to some value.  Although this value is not
    used by SOCK_RAW, it breaks a check that the address is available.  A
    perfect fix would be not use sockaddrs for ifaddrs, but that would be a
    bigger change.
    
    PR:                     298366
    Reviewed by:            pouria, bnovkov, adrian
    Differential Revision:  https://reviews.freebsd.org/D59570
    Fixes:                  948ad32ae1e0811f45e1d38f26636fefed5051f0
---
 sys/netinet/raw_ip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 45d974ff60f0..c6a5ae8272d6 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -876,7 +876,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
 
 	fib = V_rip_bind_all_fibs == 0 ? inp->inp_inc.inc_fibnum :
 	    RT_ALL_FIBS;
-
+	addr->sin_port = 0;
 	if (CK_STAILQ_EMPTY(&V_ifnet) ||
 	    (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) ||
 	    (addr->sin_addr.s_addr &&