Skip to contentSkip to conversation

Introduce mnl_socket_open2()

PATCH Applied Guillaume Nault 4 participants 11 messages Oct 2, 2015 – Oct 12, 2015 netfilter

lore
Share & tools
lore
#0 lore raw

cover Introduce mnl_socket_open2()

mnl_socket_open2() extends mnl_socket_open() with user provided flags, to be used in the socket() call.

Patch #1 implements the new function while patch #2 updates the examples by applying the SOCK_CLOEXEC flag on netlink sockets. Though it's a safe default, this flag isn't necessary for the simple programs under examples/. So feel free to drop patch #2 if considered of too little value.

Guillaume Nault (2):
socket: introduce mnl_socket_open2()
examples: use mnl_socket_open2()

 examples/genl/genl-family-get.c        |  4 ++--
 examples/genl/genl-group-events.c      |  4 ++--
 examples/kobject/kobject-event.c       |  4 ++--
 examples/netfilter/nf-log.c            |  4 ++--
 examples/netfilter/nf-queue.c          |  4 ++--
 examples/netfilter/nfct-create-batch.c |  4 ++--
 examples/netfilter/nfct-daemon.c       |  4 ++--
 examples/netfilter/nfct-dump.c         |  4 ++--
 examples/netfilter/nfct-event.c        |  4 ++--
 examples/rtnl/rtnl-addr-dump.c         |  4 ++--
 examples/rtnl/rtnl-link-dump.c         |  4 ++--
 examples/rtnl/rtnl-link-dump2.c        |  4 ++--
 examples/rtnl/rtnl-link-dump3.c        |  4 ++--
 examples/rtnl/rtnl-link-event.c        |  4 ++--
 examples/rtnl/rtnl-link-set.c          |  4 ++--
 examples/rtnl/rtnl-route-add.c         |  4 ++--
 examples/rtnl/rtnl-route-dump.c        |  4 ++--
 examples/rtnl/rtnl-route-event.c       |  4 ++--
 include/libmnl/libmnl.h                |  3 ++-
 src/libmnl.map                         |  1 +
 src/socket.c                           | 41 ++++++++++++++++++++++++++--------
 21 files changed, 71 insertions(+), 46 deletions(-)
Signature · 1 line
2.6.0
#1 lore raw

PATCH 1/2 socket: introduce mnl_socket_open2()

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +2 -1
index 3a589bc..5adb13c 100644
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
 extern struct mnl_socket *mnl_socket_fdopen(int fd);
 extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
 extern int mnl_socket_close(struct mnl_socket *nl);
src/libmnl.map +1 -0
index 3c147a7..e5920e5 100644
@@ -74,5 +74,6 @@ LIBMNL_1.1 {
 } LIBMNL_1.0;
 
 LIBMNL_1.2 {
+  mnl_socket_open2;
   mnl_socket_fdopen;
 } LIBMNL_1.1;
src/socket.c +32 -9

62 lines not on this page · raw message

Signature · 1 line
2.6.0
#2 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

Quoted 15 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +0 -0
index 3a589bc..5adb13c 100644

include/libmnl/libmnl.h extern "C" { · line 25

Quoted 6 lines
include/libmnl/libmnl.h +2 -1
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);

Looks good, but we should be using 'unsigned int flags' instead, right?

Or am I missing anything?

#3 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

Quoted 19 lines · Pablo Neira Ayuso
Quoted 18 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +0 -0
index 3a589bc..5adb13c 100644
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
Quoted 7 lines

include/libmnl/libmnl.h extern "C" { · line 25

Quoted 3 lines
include/libmnl/libmnl.h +2 -1
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);

Looks good, but we should be using 'unsigned int flags' instead, right?

Or am I missing anything?

Generally speaking, I'd also consider unsigned integers to be more appropriate for flag parameters.

But all socket() parameters are signed integers, including "type" which is bitwise OR-ed with "flags". Furthermore, others libc's functions introduced for the same purpose (race-free setting of CLOEXEC flag), also use a signed integer as flag parameter (like dup3()).

So I've used int for consistency. But I can repost if you prefer.

#4 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

In reply to Guillaume Nault

Hi,

Quoted 29 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +2 -1
index 3a589bc..5adb13c 100644
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
 extern struct mnl_socket *mnl_socket_fdopen(int fd);
 extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
 extern int mnl_socket_close(struct mnl_socket *nl);
src/libmnl.map +0 -0
index 3c147a7..e5920e5 100644

src/libmnl.map LIBMNL_1.1 { · line 79

Quoted 6 lines
src/libmnl.map +1 -0
@@ -74,5 +74,6 @@ LIBMNL_1.1 {
 } LIBMNL_1.0;
 
 LIBMNL_1.2 {
+  mnl_socket_open2;
   mnl_socket_fdopen;
 } LIBMNL_1.1;

I think this breaks library ABI: you should introduce a new revision instead.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences

          H-1525 Budapest 114, POB. 49, Hungary
#5 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

Quoted 35 lines · Jozsef Kadlecsik

Hi,

Quoted 31 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +2 -1
index 3a589bc..5adb13c 100644
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
 extern struct mnl_socket *mnl_socket_fdopen(int fd);
 extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
 extern int mnl_socket_close(struct mnl_socket *nl);
src/libmnl.map +0 -0
index 3c147a7..e5920e5 100644
@@ -74,5 +74,6 @@ LIBMNL_1.1 {
 } LIBMNL_1.0;
 
Quoted 7 lines

src/libmnl.map LIBMNL_1.1 { · line 79

Quoted 4 lines
src/libmnl.map +1 -0
 LIBMNL_1.2 {
+  mnl_socket_open2;
   mnl_socket_fdopen;
 } LIBMNL_1.1;

I think this breaks library ABI: you should introduce a new revision instead.

This would be part of the new interfaces for the next release:

src/libmnl.map +5 -0
index dbc332e..e5920e5 100644
@@ -72,3 +72,8 @@ local: *;
 LIBMNL_1.1 {
   mnl_attr_parse_payload;
 } LIBMNL_1.0;
+
+LIBMNL_1.2 {
+  mnl_socket_open2;
+  mnl_socket_fdopen;
+} LIBMNL_1.1;
#6 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

Quoted 44 lines · Pablo Neira Ayuso
Quoted 35 lines · Jozsef Kadlecsik

Hi,

Quoted 31 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +2 -1
index 3a589bc..5adb13c 100644
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
 extern struct mnl_socket *mnl_socket_fdopen(int fd);
 extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
 extern int mnl_socket_close(struct mnl_socket *nl);
src/libmnl.map +0 -0
index 3c147a7..e5920e5 100644
@@ -74,5 +74,6 @@ LIBMNL_1.1 {
 } LIBMNL_1.0;
 
Quoted 7 lines

src/libmnl.map LIBMNL_1.1 { · line 79

Quoted 4 lines
src/libmnl.map +1 -0
 LIBMNL_1.2 {
+  mnl_socket_open2;
   mnl_socket_fdopen;
 } LIBMNL_1.1;

I think this breaks library ABI: you should introduce a new revision instead.

Quoted 1 line

This would be part of the new interfaces for the next release:

That's right then, sorry for the noise :-)

Best regards,
Jozsef

Quoted 15 lines
src/libmnl.map +5 -1
index dbc332e..e5920e5 100644
@@ -72,3 +72,8 @@ local: *;
 LIBMNL_1.1 {
   mnl_attr_parse_payload;
 } LIBMNL_1.0;
+
+LIBMNL_1.2 {
+  mnl_socket_open2;
+  mnl_socket_fdopen;
+} LIBMNL_1.1;
 
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences

          H-1525 Budapest 114, POB. 49, Hungary
#7 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

In reply to Jozsef Kadlecsik
Quoted 35 lines · Jozsef Kadlecsik

Hi,

Quoted 31 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

---
 include/libmnl/libmnl.h |  3 ++-
 src/libmnl.map          |  1 +
 src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 35 insertions(+), 10 deletions(-)
include/libmnl/libmnl.h +2 -1
index 3a589bc..5adb13c 100644
@@ -21,7 +21,8 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int type);
+extern struct mnl_socket *mnl_socket_open(int bus);
+extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
 extern struct mnl_socket *mnl_socket_fdopen(int fd);
 extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
 extern int mnl_socket_close(struct mnl_socket *nl);
src/libmnl.map +0 -0
index 3c147a7..e5920e5 100644
@@ -74,5 +74,6 @@ LIBMNL_1.1 {
 } LIBMNL_1.0;
 
Quoted 8 lines

src/libmnl.map LIBMNL_1.1 { · line 79

Quoted 4 lines
src/libmnl.map +1 -0
 LIBMNL_1.2 {
+  mnl_socket_open2;
   mnl_socket_fdopen;
 } LIBMNL_1.1;

I think this breaks library ABI: you should introduce a new revision instead.

AFAIK, this revision hasn't been part of any official release yet. That's why I've exported mnl_socket_open2() there. I don't mind incrementing the ABI version, but should we really do that for every commit exporting a new function between two releases?

#8 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

Quoted 8 lines · Guillaume Nault
Quoted 4 lines

I think this breaks library ABI: you should introduce a new revision instead.

AFAIK, this revision hasn't been part of any official release yet. That's why I've exported mnl_socket_open2() there. I don't mind incrementing the ABI version, but should we really do that for every commit exporting a new function between two releases?

Not for every commit, indeed no. That would lead to a needlessy larger (and deeper) symvers DAG, and therefore more to process for dynamic and runtime linkers. Not much, but it would pile up for x->\infty. This is also why the entire DAG should be flattened again when setting -version-info C:R:A back to a new *:0:0.

maintainer Applied
#9 lore raw

Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

In reply to Guillaume Nault
Quoted 2 lines · Guillaume Nault

Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time.

Applied, thanks for your patience.

Skipping patch 2/2 though.

#10 lore raw

PATCH 2/2 examples: use mnl_socket_open2()

In reply to Guillaume Nault

Open netlink sockets with the SOCK_CLOEXEC flag to provide sample usage of the new mnl_socket_open2() function.

---
 examples/genl/genl-family-get.c        | 4 ++--
 examples/genl/genl-group-events.c      | 4 ++--
 examples/kobject/kobject-event.c       | 4 ++--
 examples/netfilter/nf-log.c            | 4 ++--
 examples/netfilter/nf-queue.c          | 4 ++--
 examples/netfilter/nfct-create-batch.c | 4 ++--
 examples/netfilter/nfct-daemon.c       | 4 ++--
 examples/netfilter/nfct-dump.c         | 4 ++--
 examples/netfilter/nfct-event.c        | 4 ++--
 examples/rtnl/rtnl-addr-dump.c         | 4 ++--
 examples/rtnl/rtnl-link-dump.c         | 4 ++--
 examples/rtnl/rtnl-link-dump2.c        | 4 ++--
 examples/rtnl/rtnl-link-dump3.c        | 4 ++--
 examples/rtnl/rtnl-link-event.c        | 4 ++--
 examples/rtnl/rtnl-link-set.c          | 4 ++--
 examples/rtnl/rtnl-route-add.c         | 4 ++--
 examples/rtnl/rtnl-route-dump.c        | 4 ++--
 examples/rtnl/rtnl-route-event.c       | 4 ++--
 18 files changed, 36 insertions(+), 36 deletions(-)
examples/genl/genl-family-get.c +2 -2
index ba8de12..d2ce56f 100644
@@ -206,9 +206,9 @@ int main(int argc, char *argv[])
 	else
 		nlh->nlmsg_flags |= NLM_F_DUMP;
 
-	nl = mnl_socket_open(NETLINK_GENERIC);
+	nl = mnl_socket_open2(NETLINK_GENERIC, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/genl/genl-group-events.c +2 -2
index d5f0a18..8a03176 100644
@@ -28,9 +28,9 @@ int main(int argc, char *argv[])
 	}
 	group = atoi(argv[1]);
 
-	nl = mnl_socket_open(NETLINK_GENERIC);
+	nl = mnl_socket_open2(NETLINK_GENERIC, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/kobject/kobject-event.c +2 -2
index 97debdf..36d9647 100644
@@ -13,9 +13,9 @@ int main(int argc, char *argv[])
 	char buf[MNL_SOCKET_BUFFER_SIZE];
 	int ret;
 
-	nl = mnl_socket_open(NETLINK_KOBJECT_UEVENT);
+	nl = mnl_socket_open2(NETLINK_KOBJECT_UEVENT, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/netfilter/nf-log.c +2 -2
index 4383b66..ebe4f15 100644
@@ -154,9 +154,9 @@ int main(int argc, char *argv[])
 	}
 	qnum = atoi(argv[1]);
 
-	nl = mnl_socket_open(NETLINK_NETFILTER);
+	nl = mnl_socket_open2(NETLINK_NETFILTER, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/netfilter/nf-queue.c +2 -2
index 957e365..78ed3e3 100644
@@ -169,9 +169,9 @@ int main(int argc, char *argv[])
 	}
 	queue_num = atoi(argv[1]);
 
-	nl = mnl_socket_open(NETLINK_NETFILTER);
+	nl = mnl_socket_open2(NETLINK_NETFILTER, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/netfilter/nfct-create-batch.c +2 -2
index 4675789..3278608 100644
@@ -139,9 +139,9 @@ int main(void)
 	unsigned int seq, portid;
 	uint16_t i;
 
-	nl = mnl_socket_open(NETLINK_NETFILTER);
+	nl = mnl_socket_open2(NETLINK_NETFILTER, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 	if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
examples/netfilter/nfct-daemon.c +2 -2
index a97c2ec..a997717 100644
@@ -264,9 +264,9 @@ int main(int argc, char *argv[])
 	nice(-20);
 
 	/* Open netlink socket to operate with netfilter */
-	nl = mnl_socket_open(NETLINK_NETFILTER);
+	nl = mnl_socket_open2(NETLINK_NETFILTER, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/netfilter/nfct-dump.c +2 -2
index 114af61..7262f04 100644
@@ -270,9 +270,9 @@ int main(void)
 	uint32_t seq, portid;
 	int ret;
 
-	nl = mnl_socket_open(NETLINK_NETFILTER);
+	nl = mnl_socket_open2(NETLINK_NETFILTER, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/netfilter/nfct-event.c +2 -2
index 94603d4..0c872fa 100644
@@ -206,9 +206,9 @@ int main(void)
 	char buf[MNL_SOCKET_BUFFER_SIZE];
 	int ret;
 
-	nl = mnl_socket_open(NETLINK_NETFILTER);
+	nl = mnl_socket_open2(NETLINK_NETFILTER, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-addr-dump.c +2 -2
index 6b4e52e..0d57df7 100644
@@ -98,9 +98,9 @@ int main(int argc, char *argv[])
 	else if (strcmp(argv[1], "inet6") == 0)
 		rt->rtgen_family = AF_INET6;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-link-dump.c +2 -2
index f5d6312..f8013b2 100644
@@ -95,9 +95,9 @@ int main(void)
 	rt = mnl_nlmsg_put_extra_header(nlh, sizeof(struct rtgenmsg));
 	rt->rtgen_family = AF_PACKET;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-link-dump2.c +2 -2
index b3ca3fa..88e4a2c 100644
@@ -68,9 +68,9 @@ int main(void)
 	rt = mnl_nlmsg_put_extra_header(nlh, sizeof(struct rtgenmsg));
 	rt->rtgen_family = AF_PACKET;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-link-dump3.c +2 -2
index 2521214..191b305 100644
@@ -68,9 +68,9 @@ int main(void)
 	rt = mnl_nlmsg_put_extra_header(nlh, sizeof(struct rtgenmsg));
 	rt->rtgen_family = AF_PACKET;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-link-event.c +2 -2
index 123fb88..4b9f80e 100644
@@ -66,9 +66,9 @@ int main(void)
 	char buf[MNL_SOCKET_BUFFER_SIZE];
 	int ret;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-link-set.c +2 -2
index 6086c37..43857ee 100644
@@ -46,9 +46,9 @@ int main(int argc, char *argv[])
 
 	mnl_attr_put_str(nlh, IFLA_IFNAME, argv[1]);
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-route-add.c +2 -2
index 97578cd..3465235 100644
@@ -92,9 +92,9 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-route-dump.c +2 -2
index 17da80b..147a801 100644
@@ -321,9 +321,9 @@ int main(int argc, char *argv[])
 	else if (strcmp(argv[1], "inet6") == 0)
 		rtm->rtm_family = AF_INET6;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
examples/rtnl/rtnl-route-event.c +2 -2
index 6cad9f0..9c79b0c 100644
@@ -311,9 +311,9 @@ int main(int argc, char *argv[])
 	char buf[MNL_SOCKET_BUFFER_SIZE];
 	int ret;
 
-	nl = mnl_socket_open(NETLINK_ROUTE);
+	nl = mnl_socket_open2(NETLINK_ROUTE, SOCK_CLOEXEC);
 	if (nl == NULL) {
-		perror("mnl_socket_open");
+		perror("mnl_socket_open2");
 		exit(EXIT_FAILURE);
 	}
 
Signature · 1 line
2.6.0