lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3ad78fb0-4aa2-424b-9e91-8c32b1c266f5@6wind.com>
Date: Tue, 15 Oct 2024 09:45:12 +0200
From: Nicolas Dichtel <nicolas.dichtel@...nd.com>
To: Xiao Liang <shaw.leon@...il.com>,
 Stephen Hemminger <stephen@...workplumber.org>, netdev@...r.kernel.org
Subject: Re: [PATCH v2 iproute2 2/2] iplink: Fix link-netns id and link
 ifindex

Le 11/10/2024 à 10:01, Xiao Liang a écrit :
> When link-netns or link-netnsid is supplied, lookup link in that netns.
> And if both netns and link-netns are given, IFLA_LINK_NETNSID should be
> the nsid of link-netns from the view of target netns, not from current
> one.
> 
> For example, when handling:
> 
>     # ip -n ns1 link add netns ns2 link-netns ns3 link eth1 eth1.100 type vlan id 100
> 
> should lookup eth1 in ns3 and IFLA_LINK_NETNSID is the id of ns3 from
> ns2.
Indeed.

> 
> Signed-off-by: Xiao Liang <shaw.leon@...il.com>
> ---
>  ip/iplink.c | 143 +++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 118 insertions(+), 25 deletions(-)
> 

[snip]

> @@ -618,20 +653,25 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
>  			if (offload && name == dev)
>  				dev = NULL;
>  		} else if (strcmp(*argv, "netns") == 0) {
> +			int pid;
> +
>  			NEXT_ARG();
>  			if (netns != -1)
>  				duparg("netns", *argv);
>  			netns = netns_get_fd(*argv);
> -			if (netns >= 0) {
> -				open_fds_add(netns);
> -				addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_FD,
> -					  &netns, 4);
> +			if (netns < 0 && get_integer(&pid, *argv, 0) == 0) {
> +				char path[PATH_MAX];
> +
> +				snprintf(path, sizeof(path), "/proc/%d/ns/net",
> +					 pid);
> +				netns = open(path, O_RDONLY);
>  			}
This chunk is added to allow the user to give a pid instead of a netns name.
It's not directly related to the patch topic. Could you put in a separate patch?

> -			else if (get_integer(&netns, *argv, 0) == 0)
> -				addattr_l(&req->n, sizeof(*req),
> -					  IFLA_NET_NS_PID, &netns, 4);
> -			else
> +			if (netns < 0)
>  				invarg("Invalid \"netns\" value\n", *argv);
> +
> +			open_fds_add(netns);
> +			addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_FD,
> +				  &netns, 4);
>  			move_netns = true;
>  		} else if (strcmp(*argv, "multicast") == 0) {
>  			NEXT_ARG();

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ