Skip to content

Commit

Permalink
Fixed compatibility for 4.10-rc2 maybe also 4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
andir committed Jan 3, 2017
1 parent 1220b32 commit a561fc0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 10 additions & 0 deletions mod/common/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "nat64/mod/stateful/fragment_db.h"
#include "nat64/mod/common/send_packet.h"

#include <net/netfilter/ipv4/nf_defrag_ipv4.h>
#include <net/netfilter/ipv6/nf_defrag_ipv6.h>


static verdict core_common(struct xlation *state)
{
Expand Down Expand Up @@ -67,6 +70,10 @@ unsigned int core_4to6(struct sk_buff *skb, const struct net_device *dev)
struct iphdr *hdr = ip_hdr(skb);
verdict result;

#ifndef UNIT_TESTING
nf_defrag_ipv4_enable(dev_net(dev));
#endif

This comment has been minimized.

Copy link
@ydahhrk

ydahhrk Jan 3, 2017

Trouble here.

nf_defrag_ipv4_enable() can sleep now. The core_*() functions however, being in a software interrupt, must not.

I would suggest rolling this back into fragment_db.c's init function. You can get the net namespace using get_net_ns_by_pid() (example).

xlation_init(&state);

if (xlator_find(dev_net(dev), &state.jool))
Expand Down Expand Up @@ -96,6 +103,9 @@ unsigned int core_6to4(struct sk_buff *skb, const struct net_device *dev)
struct ipv6hdr *hdr = ipv6_hdr(skb);
verdict result;

#ifndef UNIT_TESTING
nf_defrag_ipv6_enable(dev_net(dev));
#endif

This comment has been minimized.

Copy link
@ydahhrk

ydahhrk Jan 3, 2017

Likewise.

xlation_init(&state);

if (xlator_find(dev_net(dev), &state.jool))
Expand Down
14 changes: 9 additions & 5 deletions mod/common/nl/nl_handler2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <linux/mutex.h>
#include <linux/version.h>
#include <net/genetlink.h>
#include <linux/genetlink.h>
#include "nat64/common/types.h"
#include "nat64/mod/common/config.h"
#include "nat64/mod/common/linux_version.h"
Expand Down Expand Up @@ -42,12 +42,16 @@ static struct genl_ops ops[] = {
};

static struct genl_family jool_family = {
.id = GENL_ID_GENERATE,
.hdrsize = 0,
/* .name = GNL_JOOL_FAMILY_NAME, */
.version = 1,
.maxattr = __ATTR_MAX,
.netnsok = true,
.module = THIS_MODULE,
.ops = ops,
.n_ops = ARRAY_SIZE(ops),
.mcgrps = mc_groups,
.n_mcgrps = ARRAY_SIZE(mc_groups),
};

static DEFINE_MUTEX(config_mutex);
Expand Down Expand Up @@ -147,7 +151,7 @@ static int register_family(void)

#if LINUX_VERSION_LOWER_THAN(3, 13, 0, 7, 1)

error = genl_register_family_with_ops(&jool_family, ops, ARRAY_SIZE(ops));
error = genl_register_family(&jool_family);
if (error) {
log_err("Couldn't register family!");
return error;
Expand All @@ -160,8 +164,8 @@ static int register_family(void)
}

#else
error = genl_register_family_with_ops_groups(&jool_family, ops, mc_groups);
if (error) {
error = genl_register_family(&jool_family);
if (error) {
log_err("Family registration failed: %d", error);
return error;
}
Expand Down
5 changes: 0 additions & 5 deletions mod/stateful/fragment_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ static unsigned int hash_function(const struct packet *key)

int fragdb_init(void)
{
#ifndef UNIT_TESTING
nf_defrag_ipv6_enable();
nf_defrag_ipv4_enable();
#endif

buffer_cache = kmem_cache_create("jool_reassembly_buffers",
sizeof(struct reassembly_buffer), 0, 0, NULL);
if (!buffer_cache) {
Expand Down

0 comments on commit a561fc0

Please sign in to comment.