Update to 3.2.26 release

This commit is contained in:
Thomas Haller 2015-03-30 13:46:08 +02:00
parent da56fdcb5e
commit 1cf99d2639
5 changed files with 11 additions and 255 deletions

2
.gitignore vendored
View File

@ -15,3 +15,5 @@
/libnl-doc-3.2.25.tar.gz
/libnl-3.2.26-rc1.tar.gz
/libnl-doc-3.2.26-rc1.tar.gz
/libnl-3.2.26.tar.gz
/libnl-doc-3.2.26.tar.gz

View File

@ -1,147 +0,0 @@
From 3b0d92d7b0df034d0e98be852569a6dec771121e Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Fri, 6 Mar 2015 12:33:49 +0100
Subject: [PATCH 1/1] lib/socket: detect protocol in nl_socket_set_fd()
With support for socket option SO_PROTOCOL we don't need the protocol
argument to nl_socket_set_fd(). Maybe we should drop the protocol argument
and just not support nl_socket_set_fd() on older systems. But instead
keep the argument and allow passing -1 to autodetect it.
If the user sets a protocol option, we check via getsockopt() that the
value is correct and error out otherwise.
On older kernels, the user must set the value. Otherwise
nl_socket_set_fd() will fail.
Signed-off-by: Thomas Haller <thaller@redhat.com>
(cherry picked from commit 24d333075ab4efa1406d836b821e1484a124dbfc)
---
lib/socket.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 63 insertions(+), 9 deletions(-)
diff --git a/lib/socket.c b/lib/socket.c
index 049b8b9..b29d1da 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -29,6 +29,8 @@
#include "defs.h"
+#include "sys/socket.h"
+
#include <netlink-private/netlink.h>
#include <netlink-private/socket.h>
#include <netlink/netlink.h>
@@ -577,7 +579,12 @@ int nl_socket_get_fd(const struct nl_sock *sk)
* socket similar to nl_connect().
*
* @arg sk Netlink socket (required)
- * @arg protocol Netlink protocol to use (required)
+ * @arg protocol The socket protocol (optional). Linux 2.6.32 supports
+ * the socket option SO_PROTOCOL. In this case, you can set
+ * protocol to a negative value and let it autodetect.
+ * If you set it to a non-negative value, the detected protocol
+ * must match the one provided.
+ * To support older kernels, you must specify the protocol.
* @arg fd Socket file descriptor to use (required)
*
* Set the socket file descriptor. @fd must be valid and bind'ed.
@@ -592,7 +599,7 @@ int nl_socket_get_fd(const struct nl_sock *sk)
* possibly unusable.
*
* @retval -NLE_BAD_SOCK Netlink socket is already connected
- * @retval -NLE_INVAL Socket is not connected
+ * @retval -NLE_INVAL Socket is of unexpected type
*/
int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd)
{
@@ -600,6 +607,7 @@ int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd)
socklen_t addrlen;
char buf[64];
struct sockaddr_nl local = { 0 };
+ int so_type = -1, so_protocol = -1;
if (sk->s_fd != -1)
return -NLE_BAD_SOCK;
@@ -610,16 +618,62 @@ int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd)
err = getsockname(fd, (struct sockaddr *) &local,
&addrlen);
if (err < 0) {
- NL_DBG(4, "nl_socket_set_fd(%p): getsockname() failed with %d (%s)\n",
- sk, errno, strerror_r(errno, buf, sizeof(buf)));
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): getsockname() failed with %d (%s)\n",
+ sk, fd, errno, strerror_r(errno, buf, sizeof(buf)));
return -nl_syserr2nlerr(errno);
}
-
if (addrlen != sizeof(local))
- return -NLE_NOADDR;
+ return -NLE_INVAL;
+ if (local.nl_family != AF_NETLINK) {
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): getsockname() returned family %d instead of %d (AF_NETLINK)\n",
+ sk, fd, local.nl_family, AF_NETLINK);
+ return -NLE_INVAL;
+ }
+
+ addrlen = sizeof(so_type);
+ err = getsockopt(fd, SOL_SOCKET, SO_TYPE, &so_type, &addrlen);
+ if (err < 0) {
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): getsockopt() for SO_TYPE failed with %d (%s)\n",
+ sk, fd, errno, strerror_r(errno, buf, sizeof(buf)));
+ return -nl_syserr2nlerr(errno);
+ }
+ if (addrlen != sizeof(so_type))
+ return -NLE_INVAL;
+ if (so_type != SOCK_RAW) {
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): getsockopt() returned SO_TYPE %d instead of %d (SOCK_RAW)\n",
+ sk, fd, so_type, SOCK_RAW);
+ return -NLE_INVAL;
+ }
- if (local.nl_family != AF_NETLINK)
- return -NLE_AF_NOSUPPORT;
+#if SO_PROTOCOL
+ addrlen = sizeof(so_protocol);
+ err = getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &so_protocol, &addrlen);
+ if (err < 0) {
+ if (errno == ENOPROTOOPT)
+ goto no_so_protocol;
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): getsockopt() for SO_PROTOCOL failed with %d (%s)\n",
+ sk, fd, errno, strerror_r(errno, buf, sizeof(buf)));
+ return -nl_syserr2nlerr(errno);
+ }
+ if (addrlen != sizeof(so_protocol))
+ return -NLE_INVAL;
+ if (protocol >= 0 && protocol != so_protocol) {
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): getsockopt() for SO_PROTOCOL returned %d instead of %d\n",
+ sk, fd, so_protocol, protocol);
+ return -NLE_INVAL;
+ }
+
+ if (0)
+#endif
+ {
+no_so_protocol:
+ if (protocol < 0) {
+ NL_DBG(4, "nl_socket_set_fd(%p,%d): unknown protocol and unable to detect it via SO_PROTOCOL socket option\n",
+ sk, fd);
+ return -NLE_INVAL;
+ }
+ so_protocol = protocol;
+ }
if (sk->s_local.nl_pid != local.nl_pid) {
/* the port id differs. The socket is using a port id not managed by
@@ -629,7 +683,7 @@ int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd)
}
sk->s_local = local;
sk->s_fd = fd;
- sk->s_proto = protocol;
+ sk->s_proto = so_protocol;
return 0;
}
--
1.9.3

View File

@ -1,99 +0,0 @@
From db6d08eb00fc84ecef0b14d79cc290470cfb4e98 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 9 Mar 2015 17:16:56 +0100
Subject: [PATCH 1/1] build: revert moving unstable symbols from libnl_3 linker
section
In the past, libnl3 had only one section (libnl_3) in the
linker version script. Between 3.2.25 and 3.2.26 release,
this was cleaned up and new symbols were added to libnl_3_2_26
section. Commit d2a30fb also moved new symbols since 3.2.25
to that section.
Fedora 21 and later already uses these symbols in the previous
version (@libnl_3). Updating there would break symbol lookup.
As we have users of the unstable version from pre-3.2.26, move
those symbols back. Note that this now breaks unstable users since
d2a30fb (5 weeks ago) -- which probably are much fewer affected
users.
Fixes: d2a30fbb36d668fe64f43bddfc9c53ee0362334f
Signed-off-by: Thomas Haller <thaller@redhat.com>
(cherry picked from commit cd4f66c321c91b10776af8749a60396185f462e1)
---
libnl-3.sym | 8 ++++++--
libnl-route-3.sym | 18 +++++++++++-------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/libnl-3.sym b/libnl-3.sym
index c8ef8a3..621bfe0 100644
--- a/libnl-3.sym
+++ b/libnl-3.sym
@@ -320,13 +320,17 @@ global:
nlmsg_total_size;
nlmsg_valid_hdr;
nlmsg_validate;
+
+ # The following symbols were added during the development of 3.2.26.
+ # Keep them in libnl_3 to avoid breaking users.
+ nl_cache_pickup_checkdup;
+ nl_pickup_keep_syserr;
+
local:
*;
};
libnl_3_2_26 {
global:
- nl_cache_pickup_checkdup;
- nl_pickup_keep_syserr;
nl_socket_set_fd;
} libnl_3;
diff --git a/libnl-route-3.sym b/libnl-route-3.sym
index 139a499..03b7c4e 100644
--- a/libnl-route-3.sym
+++ b/libnl-route-3.sym
@@ -832,12 +832,9 @@ global:
rtnl_u32_set_hashmask;
rtnl_u32_set_hashtable;
rtnl_u32_set_link;
-local:
- *;
-};
-libnl_3_2_26 {
-global:
+ # The following symbols were added during the development of 3.2.26.
+ # Keep them in libnl_3 to avoid breaking users.
rtnl_class_hfsc_get_fsc;
rtnl_class_hfsc_get_rsc;
rtnl_class_hfsc_get_usc;
@@ -852,6 +849,15 @@ global:
rtnl_link_inet6_str2addrgenmode;
rtnl_qdisc_hfsc_get_defcls;
rtnl_qdisc_hfsc_set_defcls;
+ rtnl_u32_add_mark;
+ rtnl_u32_del_mark;
+
+local:
+ *;
+};
+
+libnl_3_2_26 {
+global:
rtnl_skbedit_get_action;
rtnl_skbedit_get_mark;
rtnl_skbedit_get_priority;
@@ -862,7 +868,5 @@ global:
rtnl_skbedit_set_queue_mapping;
rtnl_tc_stat2str;
rtnl_tc_str2stat;
- rtnl_u32_add_mark;
- rtnl_u32_del_mark;
rtnl_u32_get_classid;
} libnl_3;
--
1.9.3

View File

@ -1,17 +1,15 @@
Name: libnl3
Version: 3.2.26
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Convenience library for kernel netlink sockets
Group: Development/Libraries
License: LGPLv2
URL: http://www.infradead.org/~tgr/libnl/
%define fullversion %{version}-rc1
%define fullversion %{version}
Source: http://www.infradead.org/~tgr/libnl/files/libnl-%{fullversion}.tar.gz
Source1: http://www.infradead.org/~tgr/libnl/files/libnl-doc-%{fullversion}.tar.gz
Patch1: 0001-nl-socket-set-fd.patch
Patch2: 0002-fedora-symbols.patch
BuildRequires: flex bison
BuildRequires: python
@ -70,8 +68,6 @@ Python 3 bindings for libnl3
%prep
%setup -q -n libnl-%{fullversion}
%patch1 -p1 -b .0001-nl-socket-set-fd.orig
%patch2 -p1 -b .0002-fedora-symbols.orig
tar -xzf %SOURCE1
@ -128,7 +124,7 @@ popd
%doc COPYING
%{_libdir}/libnl-cli*.so.*
%{_libdir}/libnl/
%{_sbindir}/*
%{_bindir}/*
%{_mandir}/man8/*
%files doc
@ -152,6 +148,10 @@ popd
%{python3_sitearch}/netlink-*.egg-info
%changelog
* Mon Mar 30 2015 Thomas Haller <thaller@redhat.com> - 3.2.26-4
- Update to 3.2.26
- cli package brings more commands and installs them to /bin
* Mon Mar 9 2015 Thomas Haller <thaller@redhat.com> - 3.2.26-3
- Update to 3.2.26-rc1
- fix broken symbols from 3.2.26-1

View File

@ -1,2 +1,2 @@
1d2bf6120ec2f479df9aa43d876f06b9 libnl-3.2.26-rc1.tar.gz
5af8721bedc132c9fb8bcc3f2c6ee2f9 libnl-doc-3.2.26-rc1.tar.gz
c8de31b74b1c15267b5ac2927b11125c libnl-3.2.26.tar.gz
a356d3d91891d392f83a2171b83edcb2 libnl-doc-3.2.26.tar.gz