rpms/libnfnetlink/devel libnfnetlink-0.0.33-svn7211.patch, NONE, 1.1 libnfnetlink-sysheader.patch, NONE, 1.1 libnfnetlink.spec, 1.8, 1.9

Paul P Komkoff Jr (stingray) fedora-extras-commits at redhat.com
Fri Feb 22 23:47:15 UTC 2008


Author: stingray

Update of /cvs/extras/rpms/libnfnetlink/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv6877

Modified Files:
	libnfnetlink.spec 
Added Files:
	libnfnetlink-0.0.33-svn7211.patch libnfnetlink-sysheader.patch 
Log Message:
libnfnetlink-0.0.33-0.1.svn7211

libnfnetlink-0.0.33-svn7211.patch:

--- NEW FILE libnfnetlink-0.0.33-svn7211.patch ---
diff --git a/configure.in b/configure.in
index fbcbd61..6a71da3 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ AC_INIT
 
 AC_CANONICAL_SYSTEM
 
-AM_INIT_AUTOMAKE(libnfnetlink, 0.0.30)
+AM_INIT_AUTOMAKE(libnfnetlink, 0.0.33)
 
 AC_PROG_CC
 AC_EXEEXT
diff --git a/include/libnfnetlink/libnfnetlink.h b/include/libnfnetlink/libnfnetlink.h
index de77caa..37fa663 100644
--- a/include/libnfnetlink/libnfnetlink.h
+++ b/include/libnfnetlink/libnfnetlink.h
@@ -56,6 +56,9 @@ extern struct nfnl_subsys_handle *nfnl_subsys_open(struct nfnl_handle *,
 						   unsigned int);
 extern void nfnl_subsys_close(struct nfnl_subsys_handle *);
 
+/* set receive buffer size (for nfnl_catch) */
+extern void nfnl_set_rcv_buffer_size(struct nfnl_handle *h, unsigned int size);
+
 /* sending of data */
 extern int nfnl_send(struct nfnl_handle *, struct nlmsghdr *);
 extern int nfnl_sendmsg(const struct nfnl_handle *, const struct msghdr *msg,
@@ -170,7 +173,8 @@ extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int);
 extern void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 
 				 u_int16_t type, u_int32_t len,
 				 unsigned char *val);
-extern unsigned int nfnl_rcvbufsiz(struct nfnl_handle *h, unsigned int size);
+extern unsigned int nfnl_rcvbufsiz(const struct nfnl_handle *h, 
+				   unsigned int size);
 
 
 extern void nfnl_dump_packet(struct nlmsghdr *, int, char *);
diff --git a/src/libnfnetlink.c b/src/libnfnetlink.c
index 6cbc43e..6b91631 100644
--- a/src/libnfnetlink.c
+++ b/src/libnfnetlink.c
@@ -85,6 +85,7 @@ struct nfnl_handle {
 	u_int32_t		subscriptions;
 	u_int32_t		seq;
 	u_int32_t		dump;
+	u_int32_t		rcv_buffer_size;	/* for nfnl_catch */
 	struct nlmsghdr 	*last_nlhdr;
 	struct nfnl_subsys_handle subsys[NFNL_MAX_SUBSYS+1];
 };
@@ -184,6 +185,7 @@ struct nfnl_handle *nfnl_open(void)
 		goto err_close;
 	}
 	nfnlh->seq = time(NULL);
+	nfnlh->rcv_buffer_size = NFNL_BUFFSIZE;
 
 	/* don't set pid here, only first socket of process has real pid !!! 
 	 * binding to pid '0' will default */
@@ -211,6 +213,19 @@ err_free:
 }
 
 /**
+ * nfnl_set_rcv_buffer_size - set the size of the receive buffer
+ * @h: libnfnetlink handler
+ * @size: buffer size
+ *
+ * This function sets the size of the receive buffer size, i.e. the size
+ * of the buffer used by nfnl_recv. Default value is 4096 bytes.
+ */
+void nfnl_set_rcv_buffer_size(struct nfnl_handle *h, unsigned int size)
+{
+	h->rcv_buffer_size = size;
+}
+
+/**
  * nfnl_subsys_open - open a netlink subsystem
  * @nfnlh: libnfnetlink handle
  * @subsys_id: which nfnetlink subsystem we are interested in
@@ -943,7 +958,7 @@ void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa,
  *
  * This function returns the new size of the socket buffer.
  */
-unsigned int nfnl_rcvbufsiz(struct nfnl_handle *h, unsigned int size)
+unsigned int nfnl_rcvbufsiz(const struct nfnl_handle *h, unsigned int size)
 {
 	int status;
 	socklen_t socklen = sizeof(size);
@@ -1129,6 +1144,7 @@ int nfnl_check_attributes(const struct nfnl_handle *h,
 					 * the kernel which we don't understand
 					 * yet. We have to silently ignore this
 					 * for the sake of future compatibility */
+					attr = NFA_NEXT(attr, attrlen);
 					continue;
 				}
 				nfa[flavor - 1] = attr;
@@ -1190,6 +1206,7 @@ int nfnl_handle_packet(struct nfnl_handle *h, char *buf, int len)
 			return -1;
 
 		len -= rlen;
+		buf += rlen;
 	}
 	return 0;
 }
@@ -1453,52 +1470,11 @@ int nfnl_iterator_next(const struct nfnl_handle *h, struct nfnl_iterator *it)
 int nfnl_catch(struct nfnl_handle *h)
 {
 	int ret;
-	unsigned int size = NFNL_BUFFSIZE;
 
 	assert(h);
 
-	/*
-	 * Since nfqueue can send big packets, we don't know how big
-	 * must be the buffer that have to store the received data.
-	 */
-	{
-		unsigned char buf[size];
-		struct sockaddr_nl peer;
-		struct iovec iov = {
-			.iov_len = size,
-		};
-		struct msghdr msg = {
-			.msg_name = (void *) &peer,
-			.msg_namelen = sizeof(peer),
-			.msg_iov = &iov,
-			.msg_iovlen = 1,
-			.msg_control = NULL,
-			.msg_controllen = 0,
-			.msg_flags = 0
-		};
-
-		memset(&peer, 0, sizeof(peer));
-		peer.nl_family = AF_NETLINK;
-		iov.iov_base = buf;
-		iov.iov_len = size;
-
-retry:		ret = recvmsg(h->fd, &msg, MSG_PEEK);
-		if (ret == -1) {
-			/* interrupted syscall must retry */
-			if (errno == EINTR)
-				goto retry;
-			/* otherwise give up */
-			return -1;
-		}
-
-		if (msg.msg_flags & MSG_TRUNC)
-			/* maximum size of data received from netlink */
-			size = 65535;
-	}
-
-	/* now, receive data from netlink */
 	while (1) {
-		unsigned char buf[size];
+		unsigned char buf[h->rcv_buffer_size];
 
 		ret = nfnl_recv(h, buf, sizeof(buf));
 		if (ret == -1) {

libnfnetlink-sysheader.patch:

--- NEW FILE libnfnetlink-sysheader.patch ---
diff --git a/include/libnfnetlink/Makefile.am b/include/libnfnetlink/Makefile.am
index 81e14c8..ad946f0 100644
--- a/include/libnfnetlink/Makefile.am
+++ b/include/libnfnetlink/Makefile.am
@@ -1,3 +1,3 @@
 
-pkginclude_HEADERS = libnfnetlink.h linux_nfnetlink.h
+pkginclude_HEADERS = libnfnetlink.h
 
diff --git a/include/libnfnetlink/libnfnetlink.h b/include/libnfnetlink/libnfnetlink.h
index 37fa663..d8b9516 100644
--- a/include/libnfnetlink/libnfnetlink.h
+++ b/include/libnfnetlink/libnfnetlink.h
@@ -17,7 +17,7 @@
 
 #include <sys/socket.h>	/* for sa_family_t */
 #include <linux/netlink.h>
-#include <libnfnetlink/linux_nfnetlink.h>
+#include <linux/netfilter/nfnetlink.h>
 
 #ifndef NETLINK_NETFILTER
 #define NETLINK_NETFILTER 12
diff --git a/include/libnfnetlink/linux_nfnetlink.h b/include/libnfnetlink/linux_nfnetlink.h
deleted file mode 100644
index 0f9311d..0000000
--- a/include/libnfnetlink/linux_nfnetlink.h
+++ /dev/null
@@ -1,163 +0,0 @@
-#ifndef _NFNETLINK_H
-#define _NFNETLINK_H
-#include <linux/types.h>
-
-#ifndef __KERNEL__
-/* nfnetlink groups: Up to 32 maximum - backwards compatibility for userspace */
-#define NF_NETLINK_CONNTRACK_NEW 		0x00000001
-#define NF_NETLINK_CONNTRACK_UPDATE		0x00000002
-#define NF_NETLINK_CONNTRACK_DESTROY		0x00000004
-#define NF_NETLINK_CONNTRACK_EXP_NEW		0x00000008
-#define NF_NETLINK_CONNTRACK_EXP_UPDATE		0x00000010
-#define NF_NETLINK_CONNTRACK_EXP_DESTROY	0x00000020
-#endif
-
-enum nfnetlink_groups {
-	NFNLGRP_NONE,
-#define NFNLGRP_NONE			NFNLGRP_NONE
-	NFNLGRP_CONNTRACK_NEW,
-#define NFNLGRP_CONNTRACK_NEW		NFNLGRP_CONNTRACK_NEW
-	NFNLGRP_CONNTRACK_UPDATE,
-#define NFNLGRP_CONNTRACK_UPDATE	NFNLGRP_CONNTRACK_UPDATE
-	NFNLGRP_CONNTRACK_DESTROY,
-#define NFNLGRP_CONNTRACK_DESTROY	NFNLGRP_CONNTRACK_DESTROY
-	NFNLGRP_CONNTRACK_EXP_NEW,
-#define	NFNLGRP_CONNTRACK_EXP_NEW	NFNLGRP_CONNTRACK_EXP_NEW
-	NFNLGRP_CONNTRACK_EXP_UPDATE,
-#define NFNLGRP_CONNTRACK_EXP_UPDATE	NFNLGRP_CONNTRACK_EXP_UPDATE
-	NFNLGRP_CONNTRACK_EXP_DESTROY,
-#define NFNLGRP_CONNTRACK_EXP_DESTROY	NFNLGRP_CONNTRACK_EXP_DESTROY
-	__NFNLGRP_MAX,
-};
-#define NFNLGRP_MAX	(__NFNLGRP_MAX - 1)
-
-/* Generic structure for encapsulation optional netfilter information.
- * It is reminiscent of sockaddr, but with sa_family replaced
- * with attribute type. 
- * ! This should someday be put somewhere generic as now rtnetlink and
- * ! nfnetlink use the same attributes methods. - J. Schulist.
- */
-
-struct nfattr
-{
-	u_int16_t nfa_len;
-	u_int16_t nfa_type;	/* we use 15 bits for the type, and the highest
-				 * bit to indicate whether the payload is nested */
-};
-
-/* FIXME: Apart from NFNL_NFA_NESTED shamelessly copy and pasted from
- * rtnetlink.h, it's time to put this in a generic file */
-
-#define NFNL_NFA_NEST	0x8000
-#define NFA_TYPE(attr) 	((attr)->nfa_type & 0x7fff)
-
-#define NFA_ALIGNTO     4
-#define NFA_ALIGN(len)	(((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1))
-#define NFA_OK(nfa,len)	((len) > 0 && (nfa)->nfa_len >= sizeof(struct nfattr) \
-	&& (nfa)->nfa_len <= (len))
-#define NFA_NEXT(nfa,attrlen)	((attrlen) -= NFA_ALIGN((nfa)->nfa_len), \
-	(struct nfattr *)(((char *)(nfa)) + NFA_ALIGN((nfa)->nfa_len)))
-#define NFA_LENGTH(len)	(NFA_ALIGN(sizeof(struct nfattr)) + (len))
-#define NFA_SPACE(len)	NFA_ALIGN(NFA_LENGTH(len))
-#define NFA_DATA(nfa)   ((void *)(((char *)(nfa)) + NFA_LENGTH(0)))
-#define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0))
-#define NFA_NEST(skb, type) \
-({	struct nfattr *__start = (struct nfattr *)skb_tail_pointer(skb); \
-	NFA_PUT(skb, (NFNL_NFA_NEST | type), 0, NULL); \
-	__start;  })
-#define NFA_NEST_END(skb, start) \
-({      (start)->nfa_len = skb_tail_pointer(skb) - (unsigned char *)(start); \
-        (skb)->len; })
-#define NFA_NEST_CANCEL(skb, start) \
-({      if (start) \
-                skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
-        -1; })
-
-/* General form of address family dependent message.
- */
-struct nfgenmsg {
-	u_int8_t  nfgen_family;		/* AF_xxx */
-	u_int8_t  version;		/* nfnetlink version */
-	__be16    res_id;		/* resource id */
-};
-
-#define NFNETLINK_V0	0
-
-#define NFM_NFA(n)      ((struct nfattr *)(((char *)(n)) \
-        + NLMSG_ALIGN(sizeof(struct nfgenmsg))))
-#define NFM_PAYLOAD(n)  NLMSG_PAYLOAD(n, sizeof(struct nfgenmsg))
-
-/* netfilter netlink message types are split in two pieces:
- * 8 bit subsystem, 8bit operation.
- */
-
-#define NFNL_SUBSYS_ID(x)	((x & 0xff00) >> 8)
-#define NFNL_MSG_TYPE(x)	(x & 0x00ff)
-
-/* No enum here, otherwise __stringify() trick of MODULE_ALIAS_NFNL_SUBSYS()
- * won't work anymore */
-#define NFNL_SUBSYS_NONE 		0
-#define NFNL_SUBSYS_CTNETLINK		1
-#define NFNL_SUBSYS_CTNETLINK_EXP	2
-#define NFNL_SUBSYS_QUEUE		3
-#define NFNL_SUBSYS_ULOG		4
-#define NFNL_SUBSYS_COUNT		5
-
-#ifdef __KERNEL__
-
-#include <linux/netlink.h>
-#include <linux/capability.h>
-
-struct nfnl_callback
-{
-	int (*call)(struct sock *nl, struct sk_buff *skb, 
-		struct nlmsghdr *nlh, struct nfattr *cda[]);
-	u_int16_t attr_count;	/* number of nfattr's */
-};
-
-struct nfnetlink_subsystem
-{
-	const char *name;
-	__u8 subsys_id;		/* nfnetlink subsystem ID */
-	__u8 cb_count;		/* number of callbacks */
-	struct nfnl_callback *cb; /* callback for individual types */
-};
-
-extern void __nfa_fill(struct sk_buff *skb, int attrtype,
-        int attrlen, const void *data);
-#define NFA_PUT(skb, attrtype, attrlen, data) \
-({ if (skb_tailroom(skb) < (int)NFA_SPACE(attrlen)) goto nfattr_failure; \
-   __nfa_fill(skb, attrtype, attrlen, data); })
-
-extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n);
-extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n);
-
-extern void nfattr_parse(struct nfattr *tb[], int maxattr, 
-			struct nfattr *nfa, int len);
-
-#define nfattr_parse_nested(tb, max, nfa) \
-	nfattr_parse((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa)))
-
-#define nfattr_bad_size(tb, max, cta_min)				\
-({	int __i, __res = 0;						\
- 	for (__i=0; __i<max; __i++) {					\
- 		if (!cta_min[__i])					\
- 			continue;					\
- 		if (tb[__i] && NFA_PAYLOAD(tb[__i]) < cta_min[__i]){	\
- 			__res = 1;					\
- 			break;						\
- 		}							\
- 	}								\
- 	__res;								\
-})
-
-extern int nfnetlink_has_listeners(unsigned int group);
-extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, 
-			  int echo);
-extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
-
-#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
-	MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
-
-#endif	/* __KERNEL__ */
-#endif	/* _NFNETLINK_H */


Index: libnfnetlink.spec
===================================================================
RCS file: /cvs/extras/rpms/libnfnetlink/devel/libnfnetlink.spec,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- libnfnetlink.spec	20 Feb 2008 03:25:15 -0000	1.8
+++ libnfnetlink.spec	22 Feb 2008 23:46:36 -0000	1.9
@@ -1,16 +1,20 @@
+%define rev 7211
+%define basever 0.0.30
+
 Name:           libnfnetlink
-Version:        0.0.30
-Release: 2%{?dist}
+Version:        0.0.33
+Release: 0.1.svn%{rev}%{?dist}
 Summary:        Netfilter netlink userspace library
 Group:          System Environment/Libraries
 License:        GPL
 URL:            http://netfilter.org
-Source0:        http://netfilter.org/projects/libnfnetlink/files/%{name}-%{version}.tar.bz2
+Source0:        http://netfilter.org/projects/libnfnetlink/files/%{name}-%{basever}.tar.bz2
 Source1:	http://www.gnu.org/licenses/gpl.txt
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-#BuildRequires:  
-#Requires:       
+Patch0:		libnfnetlink-%{version}-svn%{rev}.patch
+Patch1:		libnfnetlink-sysheader.patch
+BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+BuildRequires:	kernel-headers
+BuildRequires:  automake autoconf libtool
 
 %description
 libnfnetlink is a userspace library that provides some low-level
@@ -22,6 +26,7 @@
 Summary:        Netfilter netlink userspace library
 Group:          Development/Libraries
 Requires:       %{name} = %{version}-%{release}
+Requires:	kernel-headers
 
 %description    devel
 libnfnetlink is a userspace library that provides some low-level
@@ -30,21 +35,22 @@
 and libnfnetlink_queue.
 
 %prep
-%setup -q
+%setup -q -n %{name}-%{basever}
 cp %{SOURCE1} LICENSE
+%patch -p1
+%patch1 -p1
 
+autoreconf -i --force
 
 %build
 %configure --disable-static
 make %{?_smp_mflags}
 
-
 %install
 rm -rf $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
 find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
 
-
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -65,6 +71,10 @@
 %{_includedir}/libnfnetlink/*.h
 
 %changelog
+* Fri Feb 22 2008 Paul P. Komkoff Jr <i at stingr.net> - 0.0.33-0.1.svn7211
+- grab latest upstream changes and fixes, along with new version number
+- do not mess with bundled nfnetlink.h, use <linux/netfilter/nfnetlink.h>
+
 * Tue Feb 19 2008 Fedora Release Engineering <rel-eng at fedoraproject.org> - 0.0.30-2
 - Autorebuild for GCC 4.3
 




More information about the fedora-extras-commits mailing list