diff mbox

ipset: Backports for the nla_put_net64() API changes

Message ID 20160623102211.GA31272@hydrogen
State Accepted
Delegated to: Jozsef Kadlecsik
Headers show

Commit Message

Neutron Soutmun June 23, 2016, 10:22 a.m. UTC
* Backports the patch "libnl: nla_put_net64():align on a 64-bit area" [1]
  by Nicolas Dichtel <nicolas.dichtel@6wind.com>

* Since the nla_put_net64() API has been changed, therefore, the
  ip_set_compat.h.in should provides the macro IPSET_NLA_PUT_NET64 that
  point to the nla_put_net64() with appropriate number of arguments.

  The build script should distinguish the API changes by detect for
  the existence of nla_put_64bit() function in include/net/netlink.h.
  This function was added in the same patches set and called by
  the nla_put_be64() that called by nla_put_net64() respectively.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=e9bbe898cbe89b17ad3993c136aa13d0431cd537

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
---
 configure.ac                                            | 10 ++++++++++
 kernel/include/linux/netfilter/ipset/ip_set_compat.h.in |  7 +++++++
 kernel/include/linux/netfilter/ipset/ip_set_counter.h   | 10 ++++++----
 kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h   |  7 ++++---
 kernel/include/uapi/linux/netfilter/ipset/ip_set.h      |  1 +
 5 files changed, 28 insertions(+), 7 deletions(-)

Comments

Pablo Neira Ayuso June 23, 2016, 10:37 a.m. UTC | #1
On Thu, Jun 23, 2016 at 05:22:11PM +0700, Neutron Soutmun wrote:
> * Backports the patch "libnl: nla_put_net64():align on a 64-bit area" [1]
>   by Nicolas Dichtel <nicolas.dichtel@6wind.com>
> 
> * Since the nla_put_net64() API has been changed, therefore, the
>   ip_set_compat.h.in should provides the macro IPSET_NLA_PUT_NET64 that
>   point to the nla_put_net64() with appropriate number of arguments.
> 
>   The build script should distinguish the API changes by detect for
>   the existence of nla_put_64bit() function in include/net/netlink.h.
>   This function was added in the same patches set and called by
>   the nla_put_be64() that called by nla_put_net64() respectively.

What are you specifically fixing with this?

The pad attribute just makes sure that, after accessing a 64-bit
payload attribute, the follow up attribute still gets aligned to
64-bits.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Neutron Soutmun June 23, 2016, 11:41 a.m. UTC | #2
On Thu, Jun 23, 2016 at 5:37 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Thu, Jun 23, 2016 at 05:22:11PM +0700, Neutron Soutmun wrote:
>> * Backports the patch "libnl: nla_put_net64():align on a 64-bit area" [1]
>>   by Nicolas Dichtel <nicolas.dichtel@6wind.com>
>>
>> * Since the nla_put_net64() API has been changed, therefore, the
>>   ip_set_compat.h.in should provides the macro IPSET_NLA_PUT_NET64 that
>>   point to the nla_put_net64() with appropriate number of arguments.
>>
>>   The build script should distinguish the API changes by detect for
>>   the existence of nla_put_64bit() function in include/net/netlink.h.
>>   This function was added in the same patches set and called by
>>   the nla_put_be64() that called by nla_put_net64() respectively.
>
> What are you specifically fixing with this?

Sorry that the patch is not clear the point.
This patch is on top of the ipset master branch, http://git.netfilter.org/ipset,
which I face a problem to build the latest ipset kernel module against
the linux-4.7~rc4-1~exp1 (Debian Experimental).

Therefore, I have backported the patch from mainline and prepared the
macro for backward compatible which
the ipset kernel module could be compiled with earlier kernel version (< 4.7)

Best regards,
Neutron Soutmun
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso June 23, 2016, 6:04 p.m. UTC | #3
On Thu, Jun 23, 2016 at 06:41:45PM +0700, Neutron Soutmun wrote:
> On Thu, Jun 23, 2016 at 5:37 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Thu, Jun 23, 2016 at 05:22:11PM +0700, Neutron Soutmun wrote:
> >> * Backports the patch "libnl: nla_put_net64():align on a 64-bit area" [1]
> >>   by Nicolas Dichtel <nicolas.dichtel@6wind.com>
> >>
> >> * Since the nla_put_net64() API has been changed, therefore, the
> >>   ip_set_compat.h.in should provides the macro IPSET_NLA_PUT_NET64 that
> >>   point to the nla_put_net64() with appropriate number of arguments.
> >>
> >>   The build script should distinguish the API changes by detect for
> >>   the existence of nla_put_64bit() function in include/net/netlink.h.
> >>   This function was added in the same patches set and called by
> >>   the nla_put_be64() that called by nla_put_net64() respectively.
> >
> > What are you specifically fixing with this?
> 
> Sorry that the patch is not clear the point.
> This patch is on top of the ipset master branch, http://git.netfilter.org/ipset,
> which I face a problem to build the latest ipset kernel module against
> the linux-4.7~rc4-1~exp1 (Debian Experimental).
> 
> Therefore, I have backported the patch from mainline and prepared the
> macro for backward compatible which
> the ipset kernel module could be compiled with earlier kernel version (< 4.7)

What is exactly the compilation error you get?

Userspace should refer to any of those _PAD attributes, so this should
be fine.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Neutron Soutmun June 23, 2016, 10:55 p.m. UTC | #4
On Fri, Jun 24, 2016 at 1:04 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Thu, Jun 23, 2016 at 06:41:45PM +0700, Neutron Soutmun wrote:
>> On Thu, Jun 23, 2016 at 5:37 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>> > On Thu, Jun 23, 2016 at 05:22:11PM +0700, Neutron Soutmun wrote:
>> >> * Backports the patch "libnl: nla_put_net64():align on a 64-bit area" [1]
>> >>   by Nicolas Dichtel <nicolas.dichtel@6wind.com>
>> >>
>> >> * Since the nla_put_net64() API has been changed, therefore, the
>> >>   ip_set_compat.h.in should provides the macro IPSET_NLA_PUT_NET64 that
>> >>   point to the nla_put_net64() with appropriate number of arguments.
>> >>
>> >>   The build script should distinguish the API changes by detect for
>> >>   the existence of nla_put_64bit() function in include/net/netlink.h.
>> >>   This function was added in the same patches set and called by
>> >>   the nla_put_be64() that called by nla_put_net64() respectively.
>> >
>> > What are you specifically fixing with this?
>>
>> Sorry that the patch is not clear the point.
>> This patch is on top of the ipset master branch, http://git.netfilter.org/ipset,
>> which I face a problem to build the latest ipset kernel module against
>> the linux-4.7~rc4-1~exp1 (Debian Experimental).
>>
>> Therefore, I have backported the patch from mainline and prepared the
>> macro for backward compatible which
>> the ipset kernel module could be compiled with earlier kernel version (< 4.7)
>
> What is exactly the compilation error you get?

=== 8< ===
/usr/src/linux-headers-4.7.0-rc4-common/include/net/netlink.h:883:59:
note: declared here
 static inline int nla_put_net64(struct sk_buff *skb, int attrtype,
__be64 value,
                                                           ^
In file included from
/home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/include/linux/netfilter/ipset/ip_set.h:458:0,
                 from
/home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/net/netfilter/xt_set.c:19:
/home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/include/linux/netfilter/ipset/ip_set_counter.h:58:9:
error: too few arguments to function ‘nla_put_net64’
         nla_put_net64(skb, IPSET_ATTR_PACKETS,
         ^
=== 8< ===

Please see the full attached build.log for more information.
As the error mention above, in the
/usr/src/linux-headers-4.7.0-rc4-common/include/net/netlink.h,
the nla_put_net64()'s API has been changed, the "int padattr" is added
as the fourth argument.

Best regards,
Neutron Soutmun
Jozsef Kadlecsik June 28, 2016, 8:23 a.m. UTC | #5
On Thu, 23 Jun 2016, Neutron Soutmun wrote:

> * Backports the patch "libnl: nla_put_net64():align on a 64-bit area" [1]
>   by Nicolas Dichtel <nicolas.dichtel@6wind.com>
> 
> * Since the nla_put_net64() API has been changed, therefore, the
>   ip_set_compat.h.in should provides the macro IPSET_NLA_PUT_NET64 that
>   point to the nla_put_net64() with appropriate number of arguments.
> 
>   The build script should distinguish the API changes by detect for
>   the existence of nla_put_64bit() function in include/net/netlink.h.
>   This function was added in the same patches set and called by
>   the nla_put_be64() that called by nla_put_net64() respectively.
> 
> [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=e9bbe898cbe89b17ad3993c136aa13d0431cd537
> 
> Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
> ---
>  configure.ac                                            | 10 ++++++++++
>  kernel/include/linux/netfilter/ipset/ip_set_compat.h.in |  7 +++++++
>  kernel/include/linux/netfilter/ipset/ip_set_counter.h   | 10 ++++++----
>  kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h   |  7 ++++---
>  kernel/include/uapi/linux/netfilter/ipset/ip_set.h      |  1 +
>  5 files changed, 28 insertions(+), 7 deletions(-)

Patch is applied, thank you. I couldn't find a simpler backport solution 
either.

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
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
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso July 1, 2016, 2:34 p.m. UTC | #6
On Fri, Jun 24, 2016 at 05:55:09AM +0700, Neutron Soutmun wrote:
> On Fri, Jun 24, 2016 at 1:04 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > What is exactly the compilation error you get?
> 
> === 8< ===
> /usr/src/linux-headers-4.7.0-rc4-common/include/net/netlink.h:883:59:
> note: declared here
>  static inline int nla_put_net64(struct sk_buff *skb, int attrtype,
> __be64 value,
>                                                            ^
> In file included from
> /home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/include/linux/netfilter/ipset/ip_set.h:458:0,
>                  from
> /home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/net/netfilter/xt_set.c:19:
> /home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/include/linux/netfilter/ipset/ip_set_counter.h:58:9:
> error: too few arguments to function ‘nla_put_net64’
>          nla_put_net64(skb, IPSET_ATTR_PACKETS,
>          ^
> === 8< ===

Thanks for explaining, I let Jozsef handle this.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jozsef Kadlecsik July 1, 2016, 7:19 p.m. UTC | #7
On Fri, 1 Jul 2016, Pablo Neira Ayuso wrote:

> On Fri, Jun 24, 2016 at 05:55:09AM +0700, Neutron Soutmun wrote:
> > On Fri, Jun 24, 2016 at 1:04 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > What is exactly the compilation error you get?
> > 
> > === 8< ===
> > /usr/src/linux-headers-4.7.0-rc4-common/include/net/netlink.h:883:59:
> > note: declared here
> >  static inline int nla_put_net64(struct sk_buff *skb, int attrtype,
> > __be64 value,
> >                                                            ^
> > In file included from
> > /home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/include/linux/netfilter/ipset/ip_set.h:458:0,
> >                  from
> > /home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/net/netfilter/xt_set.c:19:
> > /home/neutron/works/debian/mypkg/ipset/git/ipset/kernel/include/linux/netfilter/ipset/ip_set_counter.h:58:9:
> > error: too few arguments to function ?nla_put_net64?
> >          nla_put_net64(skb, IPSET_ATTR_PACKETS,
> >          ^
> > === 8< ===
> 
> Thanks for explaining, I let Jozsef handle this.

I have already applied the patch in the ipset git tree where it belongs 
to.

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
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
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 7156ab8..b73b3cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -250,6 +250,16 @@  else
 	AC_SUBST(HAVE_NLA_PUT_BE64, undef)
 fi
 
+AC_MSG_CHECKING([kernel source for nla_put_64bit])
+if test -f $ksourcedir/include/net/netlink.h && \
+   $GREP -q 'nla_put_64bit' $ksourcedir/include/net/netlink.h; then
+	AC_MSG_RESULT(yes)
+	AC_SUBST(HAVE_NLA_PUT_64BIT, define)
+else
+	AC_MSG_RESULT(no)
+	AC_SUBST(HAVE_NLA_PUT_64BIT, undef)
+fi
+
 AC_MSG_CHECKING([kernel source for portid in nl_info])
 if test -f $ksourcedir/include/linux/netlink.h && \
    $AWK '/^struct netlink_skb_parms/ {for(i=1; i<=5; i++) {getline; print}}' $ksourcedir/include/linux/netlink.h | $GREP -q 'portid;'; then
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
index 15d0763..fe24255 100644
--- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
+++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
@@ -10,6 +10,7 @@ 
 #@HAVE_ETHER_ADDR_EQUAL@ HAVE_ETHER_ADDR_EQUAL
 #@HAVE_NLA_PUT_BE16@ HAVE_NLA_PUT_BE16
 #@HAVE_NLA_PUT_BE64@ HAVE_NLA_PUT_BE64
+#@HAVE_NLA_PUT_64BIT@ HAVE_NLA_PUT_64BIT
 #@HAVE_NL_INFO_PORTID@ HAVE_NL_INFO_PORTID
 #define HAVE_NETLINK_DUMP_START_ARGS	@HAVE_NETLINK_DUMP_START_ARGS@
 #@HAVE_NS_CAPABLE@ HAVE_NS_CAPABLE
@@ -160,6 +161,12 @@  static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value)
 }
 #endif
 
+#ifdef HAVE_NLA_PUT_64BIT
+#define IPSET_NLA_PUT_NET64(skb, t, v, pa) nla_put_be64(skb, t, v, pa)
+#else
+#define IPSET_NLA_PUT_NET64(skb, t, v, pa) nla_put_be64(skb, t, v)
+#endif
+
 #ifdef HAVE_NL_INFO_PORTID
 #define NETLINK_PORTID(skb)	NETLINK_CB(skb).portid
 #else
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_counter.h b/kernel/include/linux/netfilter/ipset/ip_set_counter.h
index d61e0e5..f2f1e8f 100644
--- a/kernel/include/linux/netfilter/ipset/ip_set_counter.h
+++ b/kernel/include/linux/netfilter/ipset/ip_set_counter.h
@@ -53,10 +53,12 @@  ip_set_update_counter(struct ip_set_counter *counter,
 static inline bool
 ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter)
 {
-	return nla_put_net64(skb, IPSET_ATTR_BYTES,
-			     cpu_to_be64(ip_set_get_bytes(counter))) ||
-	       nla_put_net64(skb, IPSET_ATTR_PACKETS,
-			     cpu_to_be64(ip_set_get_packets(counter)));
+	return IPSET_NLA_PUT_NET64(skb, IPSET_ATTR_BYTES,
+				   cpu_to_be64(ip_set_get_bytes(counter)),
+				   IPSET_ATTR_PAD) ||
+	       IPSET_NLA_PUT_NET64(skb, IPSET_ATTR_PACKETS,
+				   cpu_to_be64(ip_set_get_packets(counter)),
+				   IPSET_ATTR_PAD);
 }
 
 static inline void
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h b/kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h
index b03dd6a..c6df3a1 100644
--- a/kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h
+++ b/kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h
@@ -23,9 +23,10 @@  ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo)
 {
 	/* Send nonzero parameters only */
 	return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
-		nla_put_net64(skb, IPSET_ATTR_SKBMARK,
-			      cpu_to_be64((u64)skbinfo->skbmark << 32 |
-					  skbinfo->skbmarkmask))) ||
+		IPSET_NLA_PUT_NET64(skb, IPSET_ATTR_SKBMARK,
+				    cpu_to_be64((u64)skbinfo->skbmark << 32 |
+						skbinfo->skbmarkmask),
+				    IPSET_ATTR_PAD)) ||
 	       (skbinfo->skbprio &&
 		nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
 			      cpu_to_be32(skbinfo->skbprio))) ||
diff --git a/kernel/include/uapi/linux/netfilter/ipset/ip_set.h b/kernel/include/uapi/linux/netfilter/ipset/ip_set.h
index def91b9..4a6776f 100644
--- a/kernel/include/uapi/linux/netfilter/ipset/ip_set.h
+++ b/kernel/include/uapi/linux/netfilter/ipset/ip_set.h
@@ -118,6 +118,7 @@  enum {
 	IPSET_ATTR_SKBMARK,
 	IPSET_ATTR_SKBPRIO,
 	IPSET_ATTR_SKBQUEUE,
+	IPSET_ATTR_PAD,
 	__IPSET_ATTR_ADT_MAX,
 };
 #define IPSET_ATTR_ADT_MAX	(__IPSET_ATTR_ADT_MAX - 1)