From: David Ahern <dsahern@gmail.com>
To: Riccardo Paolo Bestetti <pbl@bestov.io>
Cc: "David S. Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipv4/raw: support binding to nonlocal addresses
Date: Sun, 21 Mar 2021 11:06:25 -0600 [thread overview]
Message-ID: <ad051ee7-faaf-af4e-9a72-6315fedf63c5@gmail.com> (raw)
In-Reply-To: <20210321002045.23700-1-pbl@bestov.io>
On 3/20/21 6:20 PM, Riccardo Paolo Bestetti wrote:
> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> index 50a73178d63a..734c0332b54b 100644
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -717,6 +717,7 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
> {
> struct inet_sock *inet = inet_sk(sk);
> struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
> + struct net *net = sock_net(sk);
> u32 tb_id = RT_TABLE_LOCAL;
> int ret = -EINVAL;
> int chk_addr_ret;
> @@ -732,7 +733,8 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
> tb_id);
>
> ret = -EADDRNOTAVAIL;
> - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
> + if (!inet_can_nonlocal_bind(net, inet) &&
> + addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
> chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
> goto out;
> inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
>
Please add test cases to ipv4_addr_bind and ipv6_addr_bind in
tools/testing/selftests/net/fcnal-test.sh. The latter will verify if
IPv6 works the same or needs a change.
Also, this check duplicates the ones in __inet_bind and __inet6_bind; it
would be good to use an inline helper to reduce the duplication.
next prev parent reply other threads:[~2021-03-21 17:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 0:20 [PATCH] ipv4/raw: support binding to nonlocal addresses Riccardo Paolo Bestetti
2021-03-21 17:06 ` David Ahern [this message]
2021-11-02 14:19 ` [PATCH v2] " Riccardo Paolo Bestetti
2021-11-04 15:59 ` David Ahern
2021-11-04 17:34 ` Jakub Kicinski
2021-11-17 9:00 ` Riccardo Paolo Bestetti
2021-11-17 15:14 ` Denis Kirjanov
2021-11-18 0:14 ` Riccardo Paolo Bestetti
2021-11-18 3:59 ` David Ahern
2021-11-18 4:23 ` Jakub Kicinski
[not found] ` <CFPVQWNG02LG.3DHWUZ0JCAMVS@enhorning>
2021-11-17 3:44 ` Jakub Kicinski
2021-11-17 8:05 ` Riccardo Paolo Bestetti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad051ee7-faaf-af4e-9a72-6315fedf63c5@gmail.com \
--to=dsahern@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pbl@bestov.io \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).