From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Jonas Bonn <jonas@norrbonn.se>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: davem@davemloft.net
Subject: Re: [PATCH v2 4/5] net: ipv4: allow setting address on interface outside current namespace
Date: Wed, 6 Nov 2019 22:06:33 +0100 [thread overview]
Message-ID: <1f8a0f3e-e4ac-40c9-26e6-f14498ccdbe9@6wind.com> (raw)
In-Reply-To: <20191106053923.10414-5-jonas@norrbonn.se>
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@norrbonn.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
next prev parent reply other threads:[~2019-11-06 21:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 5:39 [PATCH v2 0/5] Add namespace awareness to Netlink methods Jonas Bonn
2019-11-06 5:39 ` [PATCH v2 1/5] rtnetlink: allow RTM_SETLINK to reference other namespaces Jonas Bonn
2019-11-06 23:38 ` Jakub Kicinski
2019-11-06 5:39 ` [PATCH v2 2/5] rtnetlink: skip namespace change if already effect Jonas Bonn
2019-11-06 5:39 ` [PATCH v2 3/5] rtnetlink: allow RTM_NEWLINK to act upon interfaces in arbitrary namespaces Jonas Bonn
2019-11-06 5:39 ` [PATCH v2 4/5] net: ipv4: allow setting address on interface outside current namespace Jonas Bonn
2019-11-06 21:06 ` Nicolas Dichtel [this message]
2019-11-06 5:39 ` [PATCH v2 5/5] net: namespace: allow setting NSIDs " Jonas Bonn
2019-11-06 22:12 ` [PATCH v2 0/5] Add namespace awareness to Netlink methods David Ahern
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=1f8a0f3e-e4ac-40c9-26e6-f14498ccdbe9@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=davem@davemloft.net \
--cc=jonas@norrbonn.se \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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
all inboxes | Powered by JetHome®