[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1f8a0f3e-e4ac-40c9-26e6-f14498ccdbe9@6wind.com>
Date: Wed, 6 Nov 2019 22:06:33 +0100
From: Nicolas Dichtel <nicolas.dichtel@...nd.com>
To: Jonas Bonn <jonas@...rbonn.se>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: davem@...emloft.net
Subject: Re: [PATCH v2 4/5] net: ipv4: allow setting address on interface
outside current namespace
Le 06/11/2019 à 06:39, Jonas Bonn a écrit :
> This patch allows an interface outside of the current namespace to be
> selected when setting a new IPv4 address for a device. This uses the
> IFA_TARGET_NETNSID attribute to select the namespace in which to search
> for the interface to act upon.
>
> Signed-off-by: Jonas Bonn <jonas@...rbonn.se>
> ---
[snip]
> @@ -922,16 +917,37 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
> struct netlink_ext_ack *extack)
> {
> struct net *net = sock_net(skb->sk);
> + struct net *tgt_net = NULL;
> struct in_ifaddr *ifa;
> struct in_ifaddr *ifa_existing;
> __u32 valid_lft = INFINITY_LIFE_TIME;
> __u32 prefered_lft = INFINITY_LIFE_TIME;
> + struct nlattr *tb[IFA_MAX+1];
> + int err;
>
> ASSERT_RTNL();
>
> - ifa = rtm_to_ifaddr(net, nlh, &valid_lft, &prefered_lft, extack);
> - if (IS_ERR(ifa))
> - return PTR_ERR(ifa);
> + err = nlmsg_parse_deprecated(nlh, sizeof(struct ifaddrmsg), tb, IFA_MAX,
> + ifa_ipv4_policy, extack);
> + if (err < 0)
> + return err;
> +
> + if (tb[IFA_TARGET_NETNSID]) {
> + int32_t netnsid = nla_get_s32(tb[IFA_TARGET_NETNSID]);
> +
> + tgt_net = rtnl_get_net_ns_capable(NETLINK_CB(skb).sk, netnsid);
> + if (IS_ERR(net)) {
if (IS_ERR(tgt_net)) ?
Nicolas
Powered by blists - more mailing lists