Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 2023 10:53:11 +0000
From:      "Alexander V. Chernikov" <melifaro@ipfw.ru>
To:        Guy Yur <guyyur@gmail.com>
Cc:        freebsd-current <freebsd-current@freebsd.org>, Gleb Smirnoff <glebius@freebsd.org>
Subject:   Re: close(2) on a PF_ROUTE socket returns -1 and sets errno to EOPNOTSUPP
Message-ID:  <72413FE7-2D56-463A-8AAA-1E48C2EAA938@ipfw.ru>
In-Reply-To: <E0687354-D58B-4FFF-8A4D-118D09A532FA@ipfw.ru>
References:  <CAC67Hz-9KMcZ_GmTxQ660M69MAt7rrku1=bGagB14wTTb0R_gg@mail.gmail.com> <E0687354-D58B-4FFF-8A4D-118D09A532FA@ipfw.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

> On 15 Jan 2023, at 13:50, Alexander V. Chernikov <melifaro@ipfw.ru> =
wrote:
>=20
>=20
>=20
>> On 14 Jan 2023, at 20:46, Guy Yur <guyyur@gmail.com> wrote:
>>=20
>> Hi,
>>=20
>> close(2) on a PF_ROUTE socket returns -1 and sets errno to =
EOPNOTSUPP.
>> I am testing 14.0-CURRENT (main branch) built today.
>> On 13.1-RELEASE-p5 close returns 0.
>>=20
>> The problem looks to be related to =
36b10ac2cd18a535cac20ccf51e3fc6c408671e8.
>>=20
>> The commit removed rts_disconnect and initialization for =
.pru_disconnect.
>> After the change, .pr_disconnect is not initialized in rtsock.c
>> so now it is set to pr_disconnect_notsupp.
>> This causes flow of:
>>  soclose()
>>  sodisconnect()
>>  so->so_proto->pr_disconnect()
>>  pr_disconnect_notsupp()
>>  return EOPNOTSUPP
>> On 13.1 it called the raw socket disconnect which returned ENOTCONN.
>>=20
>> Noticed in dhcpcd error: if_route (ADD): Operation not supported
>> dhcpcd with privsep called write() which failed with EEXIST (expected =
since
>> route already existed) and then close() which overwrote the errno to
>> EOPNOTSUPP and the parent process received back EOPNOTSUPP instead of =
EEXIST.
> Thank you for the report!
> I=E2=80=99ve created https://reviews.freebsd.org/D38059 to address the =
issue.
Landed in 42904794b804.
>>=20
>>=20
>>=20
>> Simple test program (prints error on head, no error on 13.1):
>>=20
>> #include <sys/types.h>
>> #include <sys/time.h>
>> #include <sys/socket.h>
>> #include <net/if.h>
>> #include <net/route.h>
>> #include <unistd.h>
>> #include <err.h>
>>=20
>> int main(int argc, char *argv[])
>> {
>>  int s =3D socket(PF_ROUTE, SOCK_RAW, 0);
>>  if (s =3D=3D -1)
>>    err(1, "socket()");
>>  if (close(s) =3D=3D -1)
>>    err(1, "close()");
>>  return 0;
>> }
>>=20
>>=20
>> Regards,
>> Guy Yur





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?72413FE7-2D56-463A-8AAA-1E48C2EAA938>