Skip to content

Commit 5d71c94

Browse files
committed
Compilation compatibility with kernel 4.10.
Fixes #70. Resolves incompatibilities introduced by 2456e855354415bfaeb7badaa14e11b3e02c8466 and 613dbd95723aee7abd16860745691b6c7bda20dc for kernel 4.10.
1 parent d7ec00b commit 5d71c94

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

compat.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,29 @@ int in6_pton(const char *src, int srclen,
600600
# define __GNUC_PREREQ(maj, min) 0
601601
#endif
602602

603+
/* ktime is not union anymore, since 2456e855354415bfaeb7badaa14e11b3e02c8466 */
604+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
605+
# define first_tv64 first.tv64
606+
# define last_tv64 last.tv64
607+
#else
608+
# define first_tv64 first
609+
# define last_tv64 last
610+
#endif
611+
612+
/* Offset changes made in 613dbd95723aee7abd16860745691b6c7bda20dc */
613+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
614+
static inline u_int8_t xt_family(const struct xt_action_param *par)
615+
{
616+
return par->family;
617+
}
618+
static inline const struct net_device *xt_in(const struct xt_action_param *par)
619+
{
620+
return par->in;
621+
}
622+
static inline const struct net_device *xt_out(const struct xt_action_param *par)
623+
{
624+
return par->out;
625+
}
626+
#endif
627+
603628
#endif /* COMPAT_NETFLOW_H */

ipt_NETFLOW.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,10 +3863,10 @@ static void netflow_export_stats(void)
38633863
t.pkts_selected += st->pkts_selected;
38643864
t.pkts_observed += st->pkts_observed;
38653865
#endif
3866-
t.drop.first.tv64 = min_not_zero(t.drop.first.tv64, st->drop.first.tv64);
3867-
t.drop.last.tv64 = max(t.drop.last.tv64, st->drop.last.tv64);
3868-
t.lost.first.tv64 = min_not_zero(t.lost.first.tv64, st->lost.first.tv64);
3869-
t.lost.last.tv64 = max(t.lost.last.tv64, st->lost.last.tv64);
3866+
t.drop.first_tv64 = min_not_zero(t.drop.first_tv64, st->drop.first_tv64);
3867+
t.drop.last_tv64 = max(t.drop.last_tv64, st->drop.last_tv64);
3868+
t.lost.first_tv64 = min_not_zero(t.lost.first_tv64, st->lost.first_tv64);
3869+
t.lost.last_tv64 = max(t.lost.last_tv64, st->lost.last_tv64);
38703870
}
38713871

38723872
export_stat_st(OTPL_MPSTAT, &t);
@@ -4781,8 +4781,8 @@ static unsigned int netflow_target(
47814781
const void *targinfo
47824782
# endif
47834783
#else /* since 2.6.28 */
4784-
# define if_in par->in
4785-
# define if_out par->out
4784+
# define if_in xt_in(par)
4785+
# define if_out xt_out(par)
47864786
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
47874787
const struct xt_target_param *par
47884788
# else
@@ -4809,7 +4809,7 @@ static unsigned int netflow_target(
48094809
#ifdef ENABLE_DIRECTION
48104810
const int hooknum = par->hooknum;
48114811
#endif
4812-
const int family = par->family;
4812+
const int family = xt_family(par);
48134813
#endif
48144814
struct ipt_netflow_tuple tuple;
48154815
struct ipt_netflow *nf;

ipt_NETFLOW.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ struct netflow_aggr_p {
414414
#define NETFLOW_STAT_TS(count) \
415415
do { \
416416
ktime_t kts = ktime_get_real(); \
417-
if (!(__get_cpu_var(ipt_netflow_stat)).count.first.tv64) \
417+
if (!(__get_cpu_var(ipt_netflow_stat)).count.first_tv64) \
418418
__get_cpu_var(ipt_netflow_stat).count.first = kts; \
419419
__get_cpu_var(ipt_netflow_stat).count.last = kts; \
420420
} while (0);

0 commit comments

Comments
 (0)