Skip to content

Commit 364bcd5

Browse files
committed
ipt_DF: Fix for upstream replacement of skb_make_writable with skb_ensure_writable
Signed-off-by: Leonard Crestez <[email protected]>
1 parent e8bd64a commit 364bcd5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

extensions/dontfragment/ipt_DF.c

Lines changed: 12 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,14 @@ MODULE_AUTHOR("Semyon Verchenko");
1013
MODULE_DESCRIPTION("Netfilter module to set/reset DF flag");
1114
MODULE_LICENSE("Dual BSD/GPL");
1215

16+
/*
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+
*/
20+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0))
21+
#define skb_ensure_writable(skb, len) (!skb_make_writable((skb), (len)))
22+
#endif
23+
1324
static int df_tg_check(const struct xt_tgchk_param *param)
1425
{
1526
return 0;
@@ -23,7 +34,7 @@ static unsigned int df_tg(struct sk_buff *skb, const struct xt_action_param *par
2334
__u16 old_frag_off, new_frag_off;
2435

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

0 commit comments

Comments
 (0)