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] [day] [month] [year] [list]
Message-ID: <ZQmMtO+InwpjRDmQ@nanopsycho>
Date: Tue, 19 Sep 2023 13:57:40 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: David Ahern <dsahern@...il.com>
Cc: netdev@...r.kernel.org, stephen@...workplumber.org
Subject: Re: [patch iproute2-next 2/4] devlink: introduce support for netns
 id for nested handle

Tue, Sep 19, 2023 at 09:05:57AM CEST, jiri@...nulli.us wrote:
>Tue, Sep 19, 2023 at 05:06:12AM CEST, dsahern@...il.com wrote:
>>On 9/18/23 4:54 AM, Jiri Pirko wrote:
>>>  static const enum mnl_attr_data_type
>>> @@ -2723,6 +2725,85 @@ static bool should_arr_last_handle_end(struct dl *dl, const char *bus_name,
>>>  	       !cmp_arr_last_handle(dl, bus_name, dev_name);
>>>  }
>>>  
>>> +static int32_t netns_id_by_name(const char *name)
>>> +{
>>> +	struct {
>>> +		struct nlmsghdr n;
>>> +		struct rtgenmsg g;
>>> +		char            buf[1024];
>>> +	} req = {
>>> +		.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
>>> +		.n.nlmsg_flags = NLM_F_REQUEST,
>>> +		.n.nlmsg_type = RTM_GETNSID,
>>> +		.g.rtgen_family = AF_UNSPEC,
>>> +	};
>>> +	int ret = NETNSA_NSID_NOT_ASSIGNED;
>>> +	struct rtattr *tb[NETNSA_MAX + 1];
>>> +	struct nlmsghdr *n = NULL;
>>> +	struct rtnl_handle rth;
>>> +	struct rtgenmsg *rtg;
>>> +	int len;
>>> +	int fd;
>>> +
>>> +	fd = netns_get_fd(name);
>>> +	if (fd < 0)
>>> +		return ret;
>>> +
>>> +	if (rtnl_open(&rth, 0) < 0)
>>> +		return ret;
>>> +
>>> +	addattr32(&req.n, sizeof(req), NETNSA_FD, fd);
>>> +	if (rtnl_talk(&rth, &req.n, &n) < 0)
>>> +		goto out;
>>> +
>>> +	if (n->nlmsg_type == NLMSG_ERROR)
>>> +		goto out;
>>> +
>>> +	rtg = NLMSG_DATA(n);
>>> +	len = n->nlmsg_len;
>>> +
>>> +	len -= NLMSG_SPACE(sizeof(*rtg));
>>> +	if (len < 0)
>>> +		goto out;
>>> +
>>> +	parse_rtattr(tb, NETNSA_MAX, NETNS_RTA(rtg), len);
>>> +	if (tb[NETNSA_NSID])
>>> +		ret = rta_getattr_s32(tb[NETNSA_NSID]);
>>> +
>>> +out:
>>> +	free(n);
>>> +	rtnl_close(&rth);
>>> +	close(fd);
>>> +	return ret;
>>> +}
>>
>>duplicates get_netnsid_from_name
>
>True, but that one is in "ip", that is why I decided to duplicate, for
>simplicity sake. How do you suggest to re-use it? Should I move it
>to lib? Any existing file?

Nevermind, took a stab at it in v2, just sent. Thanks!

>
>
>
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ