Skip to content

Commit

Permalink
net-firewall/ipt_netflow: revision bump
Browse files Browse the repository at this point in the history
Backport compatibility patch for Linux kernel 4.6

Package-Manager: portage-2.2.28
  • Loading branch information
Pinkbyte committed Jul 19, 2016
1 parent d45e06d commit 2ad5de1
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
61 changes: 61 additions & 0 deletions net-firewall/ipt_netflow/files/ipt_netflow-2.2-linux-4.6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
commit c16ffc6cb679b3377a0d4a30a6bbcf5e2f3d0214
Author: ABC <[email protected]>
Date: Sun May 22 22:07:14 2016 +0300

Support ETHTOOL_xLINKSETTINGS API (new in linux 4.6).

Thus, making support for 4.6 kernels.
Reference to linux commit:
https://github.com/torvalds/linux/commit/3f1ac7a700d

Fixes #56, thanks karel-un.

diff --git a/ipt_NETFLOW.c b/ipt_NETFLOW.c
index 067fd50..d27eea2 100644
--- a/ipt_NETFLOW.c
+++ b/ipt_NETFLOW.c
@@ -3904,7 +3904,13 @@ static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *d
{
struct ethtool_drvinfo info = { 0 };
const struct ethtool_ops *ops = dev->ethtool_ops;
+#ifndef ETHTOOL_GLINKSETTINGS
struct ethtool_cmd ecmd;
+#define _KSETTINGS(x, y) (x)
+#else
+ struct ethtool_link_ksettings ekmd;
+#define _KSETTINGS(x, y) (y)
+#endif
int len = size;
int n;

@@ -3933,11 +3939,11 @@ static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *d
/* only get_settings for running devices to not trigger link negotiation */
if (dev->flags & IFF_UP &&
dev->flags & IFF_RUNNING &&
- !__ethtool_get_settings(dev, &ecmd)) {
+ !_KSETTINGS(__ethtool_get_settings(dev, &ecmd), __ethtool_get_link_ksettings(dev, &ekmd))) {
char *s, *p;

/* append basic parameters: speed and port */
- switch (ethtool_cmd_speed(&ecmd)) {
+ switch (_KSETTINGS(ethtool_cmd_speed(&ecmd), ekmd.base.speed)) {
case SPEED_10000: s = "10Gb"; break;
case SPEED_2500: s = "2.5Gb"; break;
case SPEED_1000: s = "1Gb"; break;
@@ -3945,7 +3951,7 @@ static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *d
case SPEED_10: s = "10Mb"; break;
default: s = "";
}
- switch (ecmd.port) {
+ switch (_KSETTINGS(ecmd.port, ekmd.base.port)) {
case PORT_TP: p = "tp"; break;
case PORT_AUI: p = "aui"; break;
case PORT_MII: p = "mii"; break;
@@ -3964,6 +3970,7 @@ ret:
ops->complete(dev);
return size - len;
}
+#undef _KSETTINGS

static const unsigned short netdev_type[] =
{ARPHRD_NETROM, ARPHRD_ETHER, ARPHRD_AX25,
91 changes: 91 additions & 0 deletions net-firewall/ipt_netflow/ipt_netflow-2.2-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6
MY_PN="${PN/_/-}"
MY_P="${MY_PN}-${PV}"
inherit linux-info linux-mod toolchain-funcs

DESCRIPTION="Netflow iptables module"
HOMEPAGE="http://sourceforge.net/projects/ipt-netflow"
SRC_URI="mirror://sourceforge/${MY_PN}/${MY_P}.tgz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"

IUSE="debug snmp"

RDEPEND="
net-firewall/iptables
snmp? ( net-analyzer/net-snmp )
"
DEPEND="${RDEPEND}
virtual/linux-sources
virtual/pkgconfig
"

# set S before MODULE_NAMES
S="${WORKDIR}/${MY_P}"

pkg_setup() {
BUILD_TARGETS="all"
MODULE_NAMES="ipt_NETFLOW(ipt_netflow:${S})"
IPT_LIB="/usr/$(get_libdir)/xtables"
local CONFIG_CHECK="~IP_NF_IPTABLES"
use debug && CONFIG_CHECK+=" ~DEBUG_FS"
linux-mod_pkg_setup
}

src_prepare() {
sed -i \
-e 's:make -C:$(MAKE) -C:g' \
-e 's:gcc -O2:$(CC) $(CFLAGS) $(LDFLAGS):' \
-e 's:gcc:$(CC) $(CFLAGS) $(LDFLAGS):' \
Makefile.in || die

# Checking for directory is enough
sed -i -e 's:-s /etc/snmp/snmpd.conf:-d /etc/snmp:' configure || die

# bug #455984
eapply "${FILESDIR}/${PN}-2.0-configure.patch"

# Compatibility with kernel 4.6
eapply "${FILESDIR}/${P}-linux-4.6.patch"

eapply_user
}

do_conf() {
echo ./configure $*
./configure $* ${EXTRA_ECONF} || die 'configure failed'
}

src_configure() {
local IPT_VERSION="$($(tc-getPKG_CONFIG) --modversion xtables)"
# this configure script is not based on autotools
# ipt-src need to be defined, see bug #455984
do_conf \
--disable-dkms \
--ipt-lib="${IPT_LIB}" \
--ipt-src="/usr/" \
--ipt-ver="${IPT_VERSION}" \
--kdir="${KV_DIR}" \
--kver="${KV_FULL}" \
$(use debug && echo '--enable-debugfs') \
$(use snmp && echo '--enable-snmp-rules' || echo '--disable-snmp-agent')
}

src_compile() {
emake ARCH="$(tc-arch-kernel)" CC="$(tc-getCC)" all
}

src_install() {
linux-mod_src_install
exeinto "${IPT_LIB}"
doexe libipt_NETFLOW.so
use snmp && emake DESTDIR="${D}" SNMPTGSO="/usr/$(get_libdir)/snmp/dlmod/snmp_NETFLOW.so" sinstall
doheader ipt_NETFLOW.h
dodoc README*
}

0 comments on commit 2ad5de1

Please sign in to comment.