From nobody Wed Oct 18 21:11:43 2023 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S9k7C6fFfz4xX4g for ; Wed, 18 Oct 2023 21:11:51 +0000 (UTC) (envelope-from yuri@FreeBSD.org) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4S9k7B6LjMz3Grp for ; Wed, 18 Oct 2023 21:11:50 +0000 (UTC) (envelope-from yuri@FreeBSD.org) Authentication-Results: mx1.freebsd.org; dkim=none; spf=softfail (mx1.freebsd.org: 198.144.192.42 is neither permitted nor denied by domain of yuri@FreeBSD.org) smtp.mailfrom=yuri@FreeBSD.org; dmarc=none Received: from [192.168.5.3] (c-73-70-62-113.hsd1.ca.comcast.net [73.70.62.113]) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 39ILBi0D067805 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Wed, 18 Oct 2023 14:11:44 -0700 (PDT) (envelope-from yuri@FreeBSD.org) X-Authentication-Warning: shell1.rawbw.com: Host c-73-70-62-113.hsd1.ca.comcast.net [73.70.62.113] claimed to be [192.168.5.3] Content-Type: multipart/alternative; boundary="------------CkizE9p0ic9EHYXU9lF8AXUb" Message-ID: <3c68b45e-94a8-4f23-dc8a-cdfbb7d3d749@tsoft.com> Date: Wed, 18 Oct 2023 14:11:43 -0700 List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US From: Yuri To: "freebsd-net@freebsd.org" Subject: Write into the route socket fails for unclear reason X-Spamd-Bar: / X-Spamd-Result: default: False [0.92 / 15.00]; VIOLATED_DIRECT_SPF(3.50)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; NEURAL_HAM_LONG(-1.00)[-0.997]; NEURAL_HAM_SHORT(-0.68)[-0.683]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; ONCE_RECEIVED(0.10)[]; RCVD_NO_TLS_LAST(0.10)[]; R_DKIM_NA(0.00)[]; TO_DN_EQ_ADDR_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-net@freebsd.org]; RCVD_COUNT_ONE(0.00)[1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; DMARC_NA(0.00)[freebsd.org]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[yuri]; RCVD_VIA_SMTP_AUTH(0.00)[]; ASN(0.00)[asn:7961, ipnet:198.144.192.0/19, country:US]; TO_MATCH_ENVRCPT_ALL(0.00)[]; HAS_XAW(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-net@freebsd.org]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_DOM_EQ_FROM_DOM(0.00)[] X-Rspamd-Queue-Id: 4S9k7B6LjMz3Grp This is a multi-part message in MIME format. --------------CkizE9p0ic9EHYXU9lF8AXUb Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, I am troubleshooting the problem that the write call into the routing socket fails with EINVAL. The file descriptor is created like this: fd = socket(PF_ROUTE, SOCK_RAW, 0); Then the write is performed for this socket, that fails with errno=EINVAL: write(fd, buf, 168); buf has these bytes: 0:   a8 00 05 04 00 00 00 00 00 04 00 00 01 00 00 00 16:  00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 32:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 96:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 128: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 144: 00 00 00 00 00 00 00 00|10 02 00 00 c0 a8 05 01 160: 00 00 00 00 00 00 00 00 Based on the code, the first 152 bytes represent 'struct rt_msghdr'. It is followed with 16 bytes of 'struct sockaddr_in' representing the IP address 192.168.5.1. The file descriptor is valid at the moment of the write call. The structures above looks fine. Why does the write call fail then? Can anybody figure this out without the need to rebuild the kernel? Thanks, Yuri --------------CkizE9p0ic9EHYXU9lF8AXUb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi,


I am troubleshooting the problem that the write call into the routing socket fails with EINVAL.


The file descriptor is created like this:

fd = socket(PF_ROUTE, SOCK_RAW, 0);


Then the write is performed for this socket, that fails with errno=EINVAL:

write(fd, buf, 168);

buf has these bytes:

0:   a8 00 05 04 00 00 00 00 00 04 00 00 01 00 00 00
16:  00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00
32:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
48:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
64:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
96:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
128: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
144: 00 00 00 00 00 00 00 00|10 02 00 00 c0 a8 05 01
160: 00 00 00 00 00 00 00 00

Based on the code, the first 152 bytes represent 'struct rt_msghdr'.

It is followed with 16 bytes of 'struct sockaddr_in' representing the IP address 192.168.5.1.


The file descriptor is valid at the moment of the write call. The structures above looks fine.


Why does the write call fail then?


Can anybody figure this out without the need to rebuild the kernel?



Thanks,

Yuri


--------------CkizE9p0ic9EHYXU9lF8AXUb--