cregit-Linux how code gets into the kernel

Release 4.11 net/ipv4/netfilter/arpt_mangle.c

/* module that allows mangling of the arp payload */
#include <linux/module.h>
#include <linux/netfilter.h>
#include <linux/netfilter_arp/arpt_mangle.h>
#include <net/sock.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
MODULE_DESCRIPTION("arptables arp payload mangle target");


static unsigned int target(struct sk_buff *skb, const struct xt_action_param *par) { const struct arpt_mangle *mangle = par->targinfo; const struct arphdr *arp; unsigned char *arpptr; int pln, hln; if (!skb_make_writable(skb, skb->len)) return NF_DROP; arp = arp_hdr(skb); arpptr = skb_network_header(skb) + sizeof(*arp); pln = arp->ar_pln; hln = arp->ar_hln; /* We assume that pln and hln were checked in the match */ if (mangle->flags & ARPT_MANGLE_SDEV) { if (ARPT_DEV_ADDR_LEN_MAX < hln || (arpptr + hln > skb_tail_pointer(skb))) return NF_DROP; memcpy(arpptr, mangle->src_devaddr, hln); } arpptr += hln; if (mangle->flags & ARPT_MANGLE_SIP) { if (ARPT_MANGLE_ADDR_LEN_MAX < pln || (arpptr + pln > skb_tail_pointer(skb))) return NF_DROP; memcpy(arpptr, &mangle->u_s.src_ip, pln); } arpptr += pln; if (mangle->flags & ARPT_MANGLE_TDEV) { if (ARPT_DEV_ADDR_LEN_MAX < hln || (arpptr + hln > skb_tail_pointer(skb))) return NF_DROP; memcpy(arpptr, mangle->tgt_devaddr, hln); } arpptr += hln; if (mangle->flags & ARPT_MANGLE_TIP) { if (ARPT_MANGLE_ADDR_LEN_MAX < pln || (arpptr + pln > skb_tail_pointer(skb))) return NF_DROP; memcpy(arpptr, &mangle->u_t.tgt_ip, pln); } return mangle->target; }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer24086.02%110.00%
Arnaldo Carvalho de Melo186.45%330.00%
Herbert Xu155.38%220.00%
Jan Engelhardt51.79%330.00%
Joonwoo Park10.36%110.00%
Total279100.00%10100.00%


static int checkentry(const struct xt_tgchk_param *par) { const struct arpt_mangle *mangle = par->targinfo; if (mangle->flags & ~ARPT_MANGLE_MASK || !(mangle->flags & ARPT_MANGLE_MASK)) return -EINVAL; if (mangle->target != NF_DROP && mangle->target != NF_ACCEPT && mangle->target != XT_CONTINUE) return -EINVAL; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer5881.69%116.67%
Jan Engelhardt68.45%350.00%
Pablo Neira Ayuso57.04%116.67%
Patrick McHardy22.82%116.67%
Total71100.00%6100.00%

static struct xt_target arpt_mangle_reg __read_mostly = { .name = "mangle", .family = NFPROTO_ARP, .target = target, .targetsize = sizeof(struct arpt_mangle), .checkentry = checkentry, .me = THIS_MODULE, };
static int __init arpt_mangle_init(void) { return xt_register_target(&arpt_mangle_reg); }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer1381.25%133.33%
Jan Engelhardt212.50%133.33%
Andrew Morton16.25%133.33%
Total16100.00%3100.00%


static void __exit arpt_mangle_fini(void) { xt_unregister_target(&arpt_mangle_reg); }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer1386.67%133.33%
Jan Engelhardt16.67%133.33%
Andrew Morton16.67%133.33%
Total15100.00%3100.00%

module_init(arpt_mangle_init); module_exit(arpt_mangle_fini);

Overall Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer37080.26%28.70%
Jan Engelhardt204.34%939.13%
Arnaldo Carvalho de Melo183.90%313.04%
Herbert Xu183.90%28.70%
Harald Welte132.82%14.35%
Patrick McHardy122.60%313.04%
Pablo Neira Ayuso51.08%14.35%
Andrew Morton40.87%14.35%
Joonwoo Park10.22%14.35%
Total461100.00%23100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.