cregit-Linux how code gets into the kernel

Release 4.7 net/ipv4/netfilter/ipt_REJECT.c

/*
 * This is a module which is used for rejecting packets.
 */

/* (C) 1999-2001 Paul `Rusty' Russell
 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <linux/icmp.h>
#include <net/icmp.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_REJECT.h>
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
#include <linux/netfilter_bridge.h>
#endif

#include <net/netfilter/ipv4/nf_reject.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
MODULE_DESCRIPTION("Xtables: packet \"rejection\" target for IPv4");


static unsigned int reject_tg(struct sk_buff *skb, const struct xt_action_param *par) { const struct ipt_reject_info *reject = par->targinfo; int hook = par->hooknum; switch (reject->with) { case IPT_ICMP_NET_UNREACHABLE: nf_send_unreach(skb, ICMP_NET_UNREACH, hook); break; case IPT_ICMP_HOST_UNREACHABLE: nf_send_unreach(skb, ICMP_HOST_UNREACH, hook); break; case IPT_ICMP_PROT_UNREACHABLE: nf_send_unreach(skb, ICMP_PROT_UNREACH, hook); break; case IPT_ICMP_PORT_UNREACHABLE: nf_send_unreach(skb, ICMP_PORT_UNREACH, hook); break; case IPT_ICMP_NET_PROHIBITED: nf_send_unreach(skb, ICMP_NET_ANO, hook); break; case IPT_ICMP_HOST_PROHIBITED: nf_send_unreach(skb, ICMP_HOST_ANO, hook); break; case IPT_ICMP_ADMIN_PROHIBITED: nf_send_unreach(skb, ICMP_PKT_FILTERED, hook); break; case IPT_TCP_RESET: nf_send_reset(par->net, skb, hook); case IPT_ICMP_ECHOREPLY: /* Doesn't happen. */ break; } return NF_DROP; }

Contributors

PersonTokensPropCommitsCommitProp
linus torvaldslinus torvalds9560.90%216.67%
florian westphalflorian westphal2214.10%18.33%
maciej soltysiakmaciej soltysiak95.77%18.33%
herbert xuherbert xu95.77%18.33%
eric leblonderic leblond85.13%18.33%
jan engelhardtjan engelhardt53.21%325.00%
eric w. biedermaneric w. biederman42.56%18.33%
pre-gitpre-git31.92%18.33%
harald welteharald welte10.64%18.33%
Total156100.00%12100.00%


static int reject_tg_check(const struct xt_tgchk_param *par) { const struct ipt_reject_info *rejinfo = par->targinfo; const struct ipt_entry *e = par->entryinfo; if (rejinfo->with == IPT_ICMP_ECHOREPLY) { pr_info("ECHOREPLY no longer supported.\n"); return -EINVAL; } else if (rejinfo->with == IPT_TCP_RESET) { /* Must specify that it's a TCP packet */ if (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO)) { pr_info("TCP_RESET invalid for non-tcp\n"); return -EINVAL; } } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git6971.13%220.00%
jan engelhardtjan engelhardt1919.59%660.00%
harald welteharald welte77.22%110.00%
patrick mchardypatrick mchardy22.06%110.00%
Total97100.00%10100.00%

static struct xt_target reject_tg_reg __read_mostly = { .name = "REJECT", .family = NFPROTO_IPV4, .target = reject_tg, .targetsize = sizeof(struct ipt_reject_info), .table = "filter", .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD) | (1 << NF_INET_LOCAL_OUT), .checkentry = reject_tg_check, .me = THIS_MODULE, };
static int __init reject_tg_init(void) { return xt_register_target(&reject_tg_reg); }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git1275.00%125.00%
jan engelhardtjan engelhardt318.75%250.00%
daniele belluccidaniele bellucci16.25%125.00%
Total16100.00%4100.00%


static void __exit reject_tg_exit(void) { xt_unregister_target(&reject_tg_reg); }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git1280.00%133.33%
jan engelhardtjan engelhardt320.00%266.67%
Total15100.00%3100.00%

module_init(reject_tg_init); module_exit(reject_tg_exit);

Overall Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git13230.70%25.88%
linus torvaldslinus torvalds9522.09%25.88%
jan engelhardtjan engelhardt5212.09%1029.41%
patrick mchardypatrick mchardy4510.47%617.65%
harald welteharald welte235.35%411.76%
florian westphalflorian westphal225.12%12.94%
art haasart haas133.02%12.94%
eric leblonderic leblond112.56%12.94%
herbert xuherbert xu92.09%12.94%
maciej soltysiakmaciej soltysiak92.09%12.94%
bart de schuymerbart de schuymer61.40%12.94%
pablo neira ayusopablo neira ayuso51.16%12.94%
eric w. biedermaneric w. biederman40.93%12.94%
tejun heotejun heo30.70%12.94%
daniele belluccidaniele bellucci10.23%12.94%
Total430100.00%34100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}