From nobody Mon Jan 16 10:53:11 2023 X-Original-To: freebsd-current@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 4NwTQX1nDJz2p3n6 for ; Mon, 16 Jan 2023 10:53:24 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from forward502c.mail.yandex.net (forward502c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d502]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4NwTQV508dz3wlt; Mon, 16 Jan 2023 10:53:22 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ipfw.ru header.s=mail header.b=tzzJNZp0; spf=pass (mx1.freebsd.org: domain of melifaro@ipfw.ru designates 2a02:6b8:c03:500:1:45:d181:d502 as permitted sender) smtp.mailfrom=melifaro@ipfw.ru; dmarc=none Received: from sas8-838e1e461505.qloud-c.yandex.net (sas8-838e1e461505.qloud-c.yandex.net [IPv6:2a02:6b8:c1b:28d:0:640:838e:1e46]) by forward502c.mail.yandex.net (Yandex) with ESMTP id 325625EBD3; Mon, 16 Jan 2023 13:53:17 +0300 (MSK) Received: by sas8-838e1e461505.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id FrgRhh0fQ0U1-bYKK2tNP; Mon, 16 Jan 2023 13:53:16 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfw.ru; s=mail; t=1673866396; bh=x85+aGk54C/9AFKSKOE6r4k9PYMVkoKFVBCJoOv/xbY=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=tzzJNZp0Xza2ZFN6LBtMEK4z5fgCvm/bS+CHSZQhtxmDkJeUNXVseTxdfZIt4PEOK x2bQoKiVNaaRGjmwYo3436r3UYgzl4vBjliI8DlvcVnMyIrWCFhbOIKiK4EgMo8pq2 QTkoud6ITypKobsE+/jSB9wa4UEnXOYWpiScQ2Q4= Content-Type: text/plain; charset=utf-8 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.200.110.1.12\)) Subject: Re: close(2) on a PF_ROUTE socket returns -1 and sets errno to EOPNOTSUPP From: "Alexander V. Chernikov" In-Reply-To: Date: Mon, 16 Jan 2023 10:53:11 +0000 Cc: freebsd-current , Gleb Smirnoff Content-Transfer-Encoding: quoted-printable Message-Id: <72413FE7-2D56-463A-8AAA-1E48C2EAA938@ipfw.ru> References: To: Guy Yur X-Mailer: Apple Mail (2.3731.200.110.1.12) X-Spamd-Result: default: False [-3.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip6:2a02:6b8:c00::/40]; R_DKIM_ALLOW(-0.20)[ipfw.ru:s=mail]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[freebsd-current@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[ipfw.ru:+]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FREEFALL_USER(0.00)[melifaro]; ARC_NA(0.00)[]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[ipfw.ru]; RCPT_COUNT_THREE(0.00)[3]; ASN(0.00)[asn:208722, ipnet:2a02:6b8::/32, country:FI]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Queue-Id: 4NwTQV508dz3wlt X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N > On 15 Jan 2023, at 13:50, Alexander V. Chernikov = wrote: >=20 >=20 >=20 >> On 14 Jan 2023, at 20:46, Guy Yur 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 >> #include >> #include >> #include >> #include >> #include >> #include >>=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