From: David Ahern <dsa@cumulusnetworks•com>
To: David Miller <davem@davemloft•net>
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 12:18:20 -0600 [thread overview]
Message-ID: <55CA3C6C.5010606@cumulusnetworks.com> (raw)
In-Reply-To: <20150811.111457.652499160223100513.davem@davemloft.net>
On 8/11/15 12:14 PM, David Miller wrote:
> 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;
>
The intent here was to default to current behavior and to keep the
details of that in one place. If you prefer table id to always enter
with the right value I can make that happen.
David
next prev parent reply other threads:[~2015-08-11 18:18 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
2015-08-11 18:18 ` David Ahern [this message]
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=55CA3C6C.5010606@cumulusnetworks.com \
--to=dsa@cumulusnetworks$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=ddutt@cumulusnetworks$(echo .)com \
--cc=ebiederm@xmission$(echo .)com \
--cc=gospo@cumulusnetworks$(echo .)com \
--cc=hadi@mojatatu$(echo .)com \
--cc=hannes@stressinduktion$(echo .)org \
--cc=jtoppins@cumulusnetworks$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.dichtel@6wind$(echo .)com \
--cc=nikolay@cumulusnetworks$(echo .)com \
--cc=roopa@cumulusnetworks$(echo .)com \
--cc=shm@cumulusnetworks$(echo .)com \
--cc=stephen@networkplumber$(echo .)org \
--cc=svaidya@brocade$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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