On Tue, Nov 17, 2015 at 11:09:46AM +0100, Andreas Schultz wrote:
----- Original Message -----
From: "Pablo Neira Ayuso" pablo@soleta.eu To: "Andreas Schultz" aschultz@tpip.net Cc: openbsc@lists.osmocom.org, "Harald Welte" laforge@gnumonks.org Sent: Monday, November 16, 2015 6:43:55 PM Subject: Re: [PATCH 05/16] gtp-rtnl: and netns support
On Mon, Nov 16, 2015 at 04:06:46PM +0100, Andreas Schultz wrote:
diff --git a/libgtnl/src/gtp-genl.c b/libgtnl/src/gtp-genl.c index c1f60ab..9e68a30 100644 --- a/libgtnl/src/gtp-genl.c +++ b/libgtnl/src/gtp-genl.c @@ -44,6 +44,8 @@ static void gtp_build_payload(struct nlmsghdr *nlh, struct gtp_tunnel *t) { mnl_attr_put_u32(nlh, GTPA_VERSION, t->gtp_version);
- if (t->ifns > 0)
mnl_attr_put_u32(nlh, GTPA_NET_NS_FD, t->ifns);Any reason not to consider descriptor zero as valid?
ifns is a file descriptor and fd's are as far as I know always greater zero. So, I didn't see a reason to permit zero there when simply not setting the attribute would serve the same purpose.
You close(0) and then allocate a descriptor via open(...) and see what it happens.
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>
int main(void) { int fd;
close(0);
fd = open("/etc/passwd", O_RDONLY); printf("fd = %d\n", fd); }