Skip to content

Commit

Permalink
Add support for newer RHEL-based kernels.
Browse files Browse the repository at this point in the history
Fix several compilation errors being thrown in newer kernels and
remove warnings also in older ones.

Fixes #105.

This code was written by Terry Froy; I'm committing on his behalf.
  • Loading branch information
ydahhrk committed Jan 4, 2016
1 parent ea77fa6 commit b42590f
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 8 deletions.
10 changes: 10 additions & 0 deletions mod/common/send_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ verdict sendpkt_send(struct packet *in, struct packet *out)
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
# define JOOL_SKB_IGNORE_DF
#else
# ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
# define JOOL_SKB_IGNORE_DF
# endif
# endif
#endif

#ifdef JOOL_SKB_IGNORE_DF
out->skb->ignore_df = true; /* FFS, kernel. */
#else
out->skb->local_df = true; /* FFS, kernel. */
Expand Down
10 changes: 10 additions & 0 deletions mod/stateful/fragment_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ static bool equals_function(const struct packet *key1, const struct packet *key2
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
# define JOOL_INET6_HASH_FRAG
#else
# ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
# define JOOL_INET6_HASH_FRAG
# endif
# endif
#endif

#ifdef JOOL_INET6_HASH_FRAG
/**
* Hash function for IPv6 keys from reassembly.c
*/
Expand Down
40 changes: 36 additions & 4 deletions mod/stateful/nf_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,61 @@ static char *banner = "\n"


#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
#define HOOK_ARG_TYPE const struct nf_hook_ops *
# define HOOK_ARG_TYPE const struct nf_hook_ops *
#else
#define HOOK_ARG_TYPE unsigned int
# ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)
# define HOOK_ARG_TYPE const struct nf_hook_ops *
# endif
# endif
#endif

#ifndef HOOK_ARG_TYPE
# define HOOK_ARG_TYPE unsigned int
#endif

static unsigned int hook_ipv4(HOOK_ARG_TYPE hook, struct sk_buff *skb,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
const struct nf_hook_state *state)
#else
#elif !defined(RHEL_RELEASE_CODE)
const struct net_device *in, const struct net_device *out,
int (*okfn)(struct sk_buff *))
#endif

#ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)
const struct net_device *in,
const struct net_device *out,
# endif
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
const struct nf_hook_state *state)
# else
int (*okfn)(struct sk_buff *))
# endif
#endif
{
return core_4to6(skb, skb->dev);
}

static unsigned int hook_ipv6(HOOK_ARG_TYPE hook, struct sk_buff *skb,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
const struct nf_hook_state *state)
#else
#elif !defined(RHEL_RELEASE_CODE)
const struct net_device *in, const struct net_device *out,
int (*okfn)(struct sk_buff *))
#endif

#ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)
const struct net_device *in,
const struct net_device *out,
# endif
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
const struct nf_hook_state *state)
# else
int (*okfn)(struct sk_buff *))
# endif
#endif
{
return core_6to4(skb, skb->dev);
}
Expand Down
40 changes: 36 additions & 4 deletions mod/stateless/nf_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,61 @@ MODULE_PARM_DESC(disabled, "Disable the translation at the beginning of the modu


#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
#define HOOK_ARG_TYPE const struct nf_hook_ops *
# define HOOK_ARG_TYPE const struct nf_hook_ops *
#else
#define HOOK_ARG_TYPE unsigned int
# ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)
# define HOOK_ARG_TYPE const struct nf_hook_ops *
# endif
# endif
#endif

#ifndef HOOK_ARG_TYPE
# define HOOK_ARG_TYPE unsigned int
#endif

static unsigned int hook_ipv4(HOOK_ARG_TYPE hook, struct sk_buff *skb,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
const struct nf_hook_state *state)
#else
#elif !defined(RHEL_RELEASE_CODE)
const struct net_device *in, const struct net_device *out,
int (*okfn)(struct sk_buff *))
#endif

#ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)
const struct net_device *in,
const struct net_device *out,
# endif
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
const struct nf_hook_state *state)
# else
int (*okfn)(struct sk_buff *))
# endif
#endif
{
return core_4to6(skb, skb->dev);
}

static unsigned int hook_ipv6(HOOK_ARG_TYPE hook, struct sk_buff *skb,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
const struct nf_hook_state *state)
#else
#elif !defined(RHEL_RELEASE_CODE)
const struct net_device *in, const struct net_device *out,
int (*okfn)(struct sk_buff *))
#endif

#ifdef RHEL_RELEASE_CODE
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)
const struct net_device *in,
const struct net_device *out,
# endif
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
const struct nf_hook_state *state)
# else
int (*okfn)(struct sk_buff *))
# endif
#endif
{
return core_6to4(skb, skb->dev);
}
Expand Down

0 comments on commit b42590f

Please sign in to comment.