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: <alpine.LFD.2.00.1209110021150.2010@ja.ssi.bg>
Date:	Tue, 11 Sep 2012 00:54:00 +0300 (EEST)
From:	Julian Anastasov <ja@....bg>
To:	Stephen Hemminger <shemminger@...tta.com>
cc:	netdev@...r.kernel.org
Subject: Re: [PATCH 1/2] iproute2: add libgenl files


	Hello,

On Mon, 10 Sep 2012, Stephen Hemminger wrote:

> On Sat,  8 Sep 2012 12:48:24 +0300
> Julian Anastasov <ja@....bg> wrote:
> 
> > +
> > +#define GENL_INIT_REQUEST(req, family, hdrsize, ver, cmd_, flags)	\
> > +	do {								\
> > +		memset(&req, 0, sizeof(req));				\
> > +		req.n.nlmsg_type = family;				\
> > +		req.n.nlmsg_flags = flags;				\
> > +		req.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN + hdrsize);	\
> > +		req.g.cmd = cmd_;					\
> > +		req.g.version = ver;					\
> > +	} while (0)
> > +
> 
> Why not an inline function, macro code is error prone.

	The problem is that we define every request with
its own structure in GENL_DEFINE_REQUEST. We can use init
func instead of macro only if we define some base structure,
for example:

struct genl_header_base {
	struct nlmsghdr		n;
	struct genlmsghdr	g;
};

	But then we will have new prefix when accessing
request fields (b.): b.n... and b.g... It will go to all places
that use addattr_*, eg. addattr_l(&req.b.n, sizeof(req), ...)
and such places can be many if there are many attributes.

#define GENL_DEFINE_REQUEST(req, hdrsize, bufsiz)			\
struct {								\
	struct genl_header_base	b;					\
	char			buf[NLMSG_ALIGN(hdrsize) + bufsiz];	\
} req

int genl_init_request(struct genl_header_base *b,
	b_size, family, hdrsize, ver, cmd_, flags)

	Do you prefer this new variant? There will be many
places like req.n that will be changed like req.b.n.

	I'll rename libgenl_ to genl_ when we decide what
to do with the request structure.

Regards

--
Julian Anastasov <ja@....bg>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ