Skip to content

Commit 1861d0a

Browse files
committed
ipt_DF: Fix for upstream replacement of skb_make_writable with skb_ensure_writable
Signed-off-by: Leonard Crestez <lcrestez@drivenets.com>
1 parent e8bd64a commit 1861d0a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

extensions/dontfragment/ipt_DF.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef LINUX_VERSION_CODE
2+
#include <linux/version.h>
3+
#endif
14
#include <linux/module.h>
25
#include <linux/kernel.h>
36
#include <net/ip.h>
@@ -10,6 +13,12 @@ MODULE_AUTHOR("Semyon Verchenko");
1013
MODULE_DESCRIPTION("Netfilter module to set/reset DF flag");
1114
MODULE_LICENSE("Dual BSD/GPL");
1215

16+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0))
17+
# skb_make_writable was removed in this commit:
18+
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=2cf6bffc49dae26edd12af6b57c8c780590380bf
19+
#define skb_ensure_writable(skb, len) (!skb_make_writable((skb), (len)))
20+
#endif
21+
1322
static int df_tg_check(const struct xt_tgchk_param *param)
1423
{
1524
return 0;
@@ -23,7 +32,7 @@ static unsigned int df_tg(struct sk_buff *skb, const struct xt_action_param *par
2332
__u16 old_frag_off, new_frag_off;
2433

2534
/* make_writable might invoke copy-on-write, so fetch iph afterwards */
26-
if (!skb_make_writable(skb, sizeof(struct iphdr))){
35+
if (skb_ensure_writable(skb, sizeof(struct iphdr))){
2736
printk(KERN_ERR "DF: Error making skb writable\n");
2837
return NF_DROP;
2938
}

0 commit comments

Comments
 (0)