Skip to content

Commit c16ffc6

Browse files
committed
Support ETHTOOL_xLINKSETTINGS API (new in linux 4.6).
Thus, making support for 4.6 kernels. Reference to linux commit: torvalds/linux@3f1ac7a700d Fixes #56, thanks karel-un.
1 parent 18e808d commit c16ffc6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ipt_NETFLOW.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3904,7 +3904,13 @@ static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *d
39043904
{
39053905
struct ethtool_drvinfo info = { 0 };
39063906
const struct ethtool_ops *ops = dev->ethtool_ops;
3907+
#ifndef ETHTOOL_GLINKSETTINGS
39073908
struct ethtool_cmd ecmd;
3909+
#define _KSETTINGS(x, y) (x)
3910+
#else
3911+
struct ethtool_link_ksettings ekmd;
3912+
#define _KSETTINGS(x, y) (y)
3913+
#endif
39083914
int len = size;
39093915
int n;
39103916

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

39393945
/* append basic parameters: speed and port */
3940-
switch (ethtool_cmd_speed(&ecmd)) {
3946+
switch (_KSETTINGS(ethtool_cmd_speed(&ecmd), ekmd.base.speed)) {
39413947
case SPEED_10000: s = "10Gb"; break;
39423948
case SPEED_2500: s = "2.5Gb"; break;
39433949
case SPEED_1000: s = "1Gb"; break;
39443950
case SPEED_100: s = "100Mb"; break;
39453951
case SPEED_10: s = "10Mb"; break;
39463952
default: s = "";
39473953
}
3948-
switch (ecmd.port) {
3954+
switch (_KSETTINGS(ecmd.port, ekmd.base.port)) {
39493955
case PORT_TP: p = "tp"; break;
39503956
case PORT_AUI: p = "aui"; break;
39513957
case PORT_MII: p = "mii"; break;
@@ -3964,6 +3970,7 @@ static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *d
39643970
ops->complete(dev);
39653971
return size - len;
39663972
}
3973+
#undef _KSETTINGS
39673974

39683975
static const unsigned short netdev_type[] =
39693976
{ARPHRD_NETROM, ARPHRD_ETHER, ARPHRD_AX25,

0 commit comments

Comments
 (0)