[linux-yocto] [PATCH v2] ipv4: net namespace does not inherit network configurations
Bruce Ashfield
bruce.ashfield at windriver.com
Mon Oct 29 09:01:03 PDT 2018
On 2018-10-28 11:30 PM, He Zhe wrote:
>
>
> On 2018/10/29 10:52, Bruce Ashfield wrote:
>> Looks fine to me.
>>
>> And to confirm, this is for 4.18, correct ?
>
> This is for linux-yocto-dev standard/base, linux-yocto v4.18/standard/base.
Sounds good. It is merged to those kernels now, and I've queued
the patch so any future kernels should have it by default.
Bruce
>
> Zhe
>
>>
>> Bruce
>>
>> On 2018-10-28 10:24 PM, zhe.he at windriver.com wrote:
>>> From: He Zhe <zhe.he at windriver.com>
>>>
>>> patch from https://lkml.org/lkml/2014/7/29/119
>>>
>>> Ipv4 net namespace requires a similar logic change as commit a79ca223e029
>>> [ipv6: fix bad free of addrconf_init_net] introduces for newer kernels.
>>>
>>> Since a net namespace is independent to another. That is, there
>>> is no any relationship between the net namespaces. So a new net
>>> namespace should not inherit network configurations from another
>>> net namespace including the host.
>>>
>>> CC: Hong Zhiguo <honkiko at gmail.com>
>>> CC: David S. Miller <davem at davemloft.net>
>>> Signed-off-by: Zhu Yanjun <zyjzyj2000 at gmail.com>
>>> Signed-off-by: yzhu1 <yanjun.zhu at windriver.com>
>>>
>>> The patch was submitted upstream (https://lkml.org/lkml/2014/7/29/119), but
>>> did not get any significant discussion and was not rejected, and also was
>>> not merged. It still makes sense for Yocto linux kernel.
>>>
>>> Signed-off-by: He Zhe <zhe.he at windriver.com>
>>> ---
>>> v2: Add summary about the status of the patch
>>>
>>> This is for linux-yocto-dev, linux-yocto master and 4.18 branches.
>>>
>>> net/ipv4/devinet.c | 29 ++++++++++++-----------------
>>> 1 file changed, 12 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
>>> index a34602a..8df4a72 100644
>>> --- a/net/ipv4/devinet.c
>>> +++ b/net/ipv4/devinet.c
>>> @@ -2560,28 +2560,23 @@ static __net_init int devinet_init_net(struct net *net)
>>> #endif
>>> err = -ENOMEM;
>>> - all = &ipv4_devconf;
>>> - dflt = &ipv4_devconf_dflt;
>>> + all = kmemdup(&ipv4_devconf, sizeof(ipv4_devconf), GFP_KERNEL);
>>> + if (all == NULL)
>>> + goto err_alloc_all;
>>> - if (!net_eq(net, &init_net)) {
>>> - all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL);
>>> - if (!all)
>>> - goto err_alloc_all;
>>> -
>>> - dflt = kmemdup(dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
>>> - if (!dflt)
>>> - goto err_alloc_dflt;
>>> + dflt = kmemdup(&ipv4_devconf_dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
>>> + if (dflt == NULL)
>>> + goto err_alloc_dflt;
>>> #ifdef CONFIG_SYSCTL
>>> - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
>>> - if (!tbl)
>>> - goto err_alloc_ctl;
>>> + tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
>>> + if (tbl == NULL)
>>> + goto err_alloc_ctl;
>>> - tbl[0].data = &all->data[IPV4_DEVCONF_FORWARDING - 1];
>>> - tbl[0].extra1 = all;
>>> - tbl[0].extra2 = net;
>>> + tbl[0].data = &all->data[IPV4_DEVCONF_FORWARDING - 1];
>>> + tbl[0].extra1 = all;
>>> + tbl[0].extra2 = net;
>>> #endif
>>> - }
>>> #ifdef CONFIG_SYSCTL
>>> err = __devinet_sysctl_register(net, "all", NETCONFA_IFINDEX_ALL, all);
>>>
>>
>>
>
More information about the linux-yocto
mailing list