From: David Miller <davem@davemloft.net>
To: dsa@cumulusnetworks.com
Cc: netdev@vger.kernel.org, shm@cumulusnetworks.com,
roopa@cumulusnetworks.com, gospo@cumulusnetworks.com,
jtoppins@cumulusnetworks.com, nikolay@cumulusnetworks.com,
ddutt@cumulusnetworks.com, hannes@stressinduktion.org,
nicolas.dichtel@6wind.com, stephen@networkplumber.org,
hadi@mojatatu.com, ebiederm@xmission.com, svaidya@brocade.com
Subject: Re: [PATCH net-next 6/9] net: Fix up inet_addr_type checks
Date: Tue, 11 Aug 2015 11:14:57 -0700 (PDT) [thread overview]
Message-ID: <20150811.111457.652499160223100513.davem@davemloft.net> (raw)
In-Reply-To: <1439229037-79213-7-git-send-email-dsa@cumulusnetworks.com>
From: David Ahern <dsa@cumulusnetworks.com>
Date: Mon, 10 Aug 2015 11:50:33 -0600
> @@ -427,6 +428,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
> struct net *net = sock_net(sk);
> unsigned short snum;
> int chk_addr_ret;
> + int tb_id = 0;
> int err;
>
> /* If the socket has its own bind function then use it. (RAW) */
> @@ -448,7 +450,16 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
> goto out;
> }
>
> - chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
> + if (sk->sk_bound_dev_if) {
> + struct net_device *dev;
> +
> + rcu_read_lock();
> + dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
> + if (dev)
> + tb_id = vrf_dev_table_rcu(dev);
> + rcu_read_unlock();
> + }
> + chk_addr_ret = inet_addr_type_table(net, addr->sin_addr.s_addr, tb_id);
>
> /* Not specified by any standard per-se, however it breaks too
> * many applications when removed. It is unfortunate since
...
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index b11321a8e58d..d84ae0e30369 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -226,6 +226,9 @@ static inline unsigned int __inet_dev_addr_type(struct net *net,
>
> rcu_read_lock();
>
> + if (!tb_id)
> + tb_id = RT_TABLE_LOCAL;
> +
> table = fib_get_table(net, tb_id);
All of this code that quietly translates table ID zero into RT_TABLE_LOCAL is
confusing.
It would be so much easier to understand if the code was structured like:
int tb_id = RT_TABLE_LOCAL;
if (doing_vrf_stuff)
tb_id = foo;
next prev parent reply other threads:[~2015-08-11 18:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 17:50 [PATCH net-next 00/10] VRF-lite - v5 David Ahern
2015-08-10 17:50 ` [PATCH net-next 1/9] net: Introduce VRF related flags and helpers David Ahern
2015-08-11 18:08 ` David Miller
2015-08-10 17:50 ` [PATCH net-next 2/9] net: Use VRF device index for lookups on RX David Ahern
2015-08-10 17:50 ` [PATCH net-next 3/9] net: Use VRF device index for lookups on TX David Ahern
2015-08-10 17:50 ` [PATCH net-next 4/9] udp: Handle VRF device in sendmsg David Ahern
2015-08-10 17:50 ` [PATCH net-next 5/9] net: Add inet_addr lookup by table David Ahern
2015-08-10 17:50 ` [PATCH net-next 6/9] net: Fix up inet_addr_type checks David Ahern
2015-08-11 18:14 ` David Miller [this message]
2015-08-11 18:18 ` David Ahern
2015-08-11 18:51 ` David Miller
2015-08-10 17:50 ` [PATCH net-next 7/9] net: Add routes to the table associated with the device David Ahern
2015-08-10 17:50 ` [PATCH net-next 8/9] net: Use passed in table for nexthop lookups David Ahern
2015-08-10 17:50 ` [PATCH net-next 9/9] net: Introduce VRF device driver David Ahern
2015-08-10 17:50 ` [PATCH] iproute2: Add support for VRF device David Ahern
2015-08-11 19:17 ` Nikolay Aleksandrov
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=20150811.111457.652499160223100513.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=ddutt@cumulusnetworks.com \
--cc=dsa@cumulusnetworks.com \
--cc=ebiederm@xmission.com \
--cc=gospo@cumulusnetworks.com \
--cc=hadi@mojatatu.com \
--cc=hannes@stressinduktion.org \
--cc=jtoppins@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
--cc=shm@cumulusnetworks.com \
--cc=stephen@networkplumber.org \
--cc=svaidya@brocade.com \
/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).