Re: [PATCH 3/5] rtnetlink: allow RTM_NEWLINK to act upon interfaces in arbitrary namespaces

From: Nicolas Dichtel
Date: Tue Nov 05 2019 - 10:43:24 EST


Le 05/11/2019 Ã 09:11, Jonas Bonn a ÃcritÂ:
> RTM_NEWLINK can be used mostly interchangeably with RTM_SETLINK for
> modifying device configuration. As such, this method requires the same
> logic as RTM_SETLINK for finding the device to act on.
>
> With this patch, the IFLA_TARGET_NETNSID selects the namespace in which
> to search for the interface to act upon. This allows, for example, to
> set the namespace of an interface outside the current namespace by
> selecting it with the (IFLA_TARGET_NETNSID,ifi->ifi_index) pair and
> specifying the namespace with one of IFLA_NET_NS_[PID|FD].
>
> Since rtnl_newlink branches off into do_setlink, we need to provide the
> same backwards compatibility check as we do for RTM_SETLINK: if the
> device is not found in the namespace given by IFLA_TARGET_NETNSID then
> we search for it in the current namespace. If found there, it's
> namespace will be changed, as before.
>
> Signed-off-by: Jonas Bonn <jonas@xxxxxxxxxxx>
Acked-by: Nicolas Dichtel <nicolas.dichtel@xxxxxxxxx>