···241241242242---------------------------243243244244-What (Why):245245- - xt_recent: the old ipt_recent proc dir246246- (superseded by /proc/net/xt_recent)247247-248248-When: January 2009 or Linux 2.7.0, whichever comes first249249-Why: Superseded by newer revisions or modules250250-Who: Jan Engelhardt <jengelh@computergmbh.de>251251-252252----------------------------253253-254244What: GPIO autorequest on gpio_direction_{input,output}() in gpiolib255245When: February 2010256246Why: All callers should use explicit gpio_request()/gpio_free().···618628 with no impact.619629620630Who: Wey-Yi Guy <wey-yi.w.guy@intel.com>631631+632632+---------------------------633633+634634+What: xt_NOTRACK635635+Files: net/netfilter/xt_NOTRACK.c636636+When: April 2011637637+Why: Superseded by xt_CT638638+Who: Netfilter developer team <netfilter-devel@vger.kernel.org>
···113113 unsigned int expect_new;114114 unsigned int expect_create;115115 unsigned int expect_delete;116116+ unsigned int search_restart;116117};117118118119/* call to create an explicit dependency on nf_conntrack. */
···11#ifndef _X_TABLES_H22#define _X_TABLES_H33-33+#include <linux/kernel.h>44#include <linux/types.h>5566#define XT_FUNCTION_MAXNAMELEN 3077+#define XT_EXTENSION_MAXNAMELEN 2978#define XT_TABLE_MAXNAMELEN 3289910struct xt_entry_match {···1312 __u16 match_size;14131514 /* Used by userspace */1616- char name[XT_FUNCTION_MAXNAMELEN-1];1717-1515+ char name[XT_EXTENSION_MAXNAMELEN];1816 __u8 revision;1917 } user;2018 struct {···3636 __u16 target_size;37373838 /* Used by userspace */3939- char name[XT_FUNCTION_MAXNAMELEN-1];4040-3939+ char name[XT_EXTENSION_MAXNAMELEN];4140 __u8 revision;4241 } user;4342 struct {···6970/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision7071 * kernel supports, if >= revision. */7172struct xt_get_revision {7272- char name[XT_FUNCTION_MAXNAMELEN-1];7373-7373+ char name[XT_EXTENSION_MAXNAMELEN];7474 __u8 revision;7575};7676···9193 __u64 u64;9294};93959494-#define XT_ALIGN(s) ALIGN((s), __alignof__(struct _xt_align))9696+#define XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _xt_align))95979698/* Standard return verdict, or do jump. */9799#define XT_STANDARD_TARGET ""···195197 * @family: Actual NFPROTO_* through which the function is invoked196198 * (helpful when match->family == NFPROTO_UNSPEC)197199 * @hotdrop: drop packet if we had inspection problems200200+ * Network namespace obtainable using dev_net(in/out)198201 */199202struct xt_match_param {200203 const struct net_device *in, *out;···212213 * struct xt_mtchk_param - parameters for match extensions'213214 * checkentry functions214215 *216216+ * @net: network namespace through which the check was invoked215217 * @table: table the rule is tried to be inserted into216218 * @entryinfo: the family-specific rule data217217- * (struct ipt_ip, ip6t_ip, ebt_entry)219219+ * (struct ipt_ip, ip6t_ip, arpt_arp or (note) ebt_entry)218220 * @match: struct xt_match through which this function was invoked219221 * @matchinfo: per-match data220222 * @hook_mask: via which hooks the new rule is reachable223223+ * Other fields as above.221224 */222225struct xt_mtchk_param {223226 struct net *net;···231230 u_int8_t family;232231};233232234234-/* Match destructor parameters */233233+/**234234+ * struct xt_mdtor_param - match destructor parameters235235+ * Fields as above.236236+ */235237struct xt_mtdtor_param {236238 struct net *net;237239 const struct xt_match *match;···289285struct xt_match {290286 struct list_head list;291287292292- const char name[XT_FUNCTION_MAXNAMELEN-1];288288+ const char name[XT_EXTENSION_MAXNAMELEN];293289 u_int8_t revision;294290295291 /* Return true or false: return FALSE and set *hotdrop = 1 to···301297 const struct xt_match_param *);302298303299 /* Called when user tries to insert an entry of this type. */304304- bool (*checkentry)(const struct xt_mtchk_param *);300300+ int (*checkentry)(const struct xt_mtchk_param *);305301306302 /* Called when entry of this type deleted. */307303 void (*destroy)(const struct xt_mtdtor_param *);···312308#endif313309 /* Set this to THIS_MODULE if you are a module, otherwise NULL */314310 struct module *me;315315-316316- /* Free to use by each match */317317- unsigned long data;318311319312 const char *table;320313 unsigned int matchsize;···328327struct xt_target {329328 struct list_head list;330329331331- const char name[XT_FUNCTION_MAXNAMELEN-1];330330+ const char name[XT_EXTENSION_MAXNAMELEN];331331+ u_int8_t revision;332332333333 /* Returns verdict. Argument order changed since 2.6.9, as this334334 must now handle non-linear skbs, using skb_copy_bits and···340338 /* Called when user tries to insert an entry of this type:341339 hook_mask is a bitmask of hooks from which it can be342340 called. */343343- /* Should return true or false. */344344- bool (*checkentry)(const struct xt_tgchk_param *);341341+ /* Should return true or false, or an error code (-Exxxx). */342342+ int (*checkentry)(const struct xt_tgchk_param *);345343346344 /* Called when entry of this type deleted. */347345 void (*destroy)(const struct xt_tgdtor_param *);···362360 unsigned short proto;363361364362 unsigned short family;365365- u_int8_t revision;366363};367364368365/* Furniture shopping... */···399398 unsigned int hook_entry[NF_INET_NUMHOOKS];400399 unsigned int underflow[NF_INET_NUMHOOKS];401400401401+ /*402402+ * Number of user chains. Since tables cannot have loops, at most403403+ * @stacksize jumps (number of user chains) can possibly be made.404404+ */405405+ unsigned int stacksize;406406+ unsigned int *stackptr;407407+ void ***jumpstack;402408 /* ipt_entry tables: one per CPU */403409 /* Note : this field MUST be the last one, see XT_TABLE_INFO_SZ */404410 void *entries[1];···441433442434extern struct xt_match *xt_find_match(u8 af, const char *name, u8 revision);443435extern struct xt_target *xt_find_target(u8 af, const char *name, u8 revision);436436+extern struct xt_match *xt_request_find_match(u8 af, const char *name,437437+ u8 revision);444438extern struct xt_target *xt_request_find_target(u8 af, const char *name,445439 u8 revision);446440extern int xt_find_revision(u8 af, const char *name, u8 revision,···608598 compat_u64 u64;609599};610600611611-#define COMPAT_XT_ALIGN(s) ALIGN((s), __alignof__(struct _compat_xt_align))601601+#define COMPAT_XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _compat_xt_align))612602613603extern void xt_compat_lock(u_int8_t af);614604extern void xt_compat_unlock(u_int8_t af);
+1-21
include/linux/netfilter/xt_CONNMARK.h
···11#ifndef _XT_CONNMARK_H_target22#define _XT_CONNMARK_H_target3344-#include <linux/types.h>55-66-/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>77- * by Henrik Nordstrom <hno@marasystems.com>88- *99- * This program is free software; you can redistribute it and/or modify1010- * it under the terms of the GNU General Public License as published by1111- * the Free Software Foundation; either version 2 of the License, or1212- * (at your option) any later version.1313- */1414-1515-enum {1616- XT_CONNMARK_SET = 0,1717- XT_CONNMARK_SAVE,1818- XT_CONNMARK_RESTORE1919-};2020-2121-struct xt_connmark_tginfo1 {2222- __u32 ctmark, ctmask, nfmask;2323- __u8 mode;2424-};44+#include <linux/netfilter/xt_connmark.h>255266#endif /*_XT_CONNMARK_H_target*/
···41414242#define BRNF_PKT_TYPE 0x014343#define BRNF_BRIDGED_DNAT 0x024444-#define BRNF_DONT_TAKE_PARENT 0x044545-#define BRNF_BRIDGED 0x084646-#define BRNF_NF_BRIDGE_PREROUTING 0x104747-4444+#define BRNF_BRIDGED 0x044545+#define BRNF_NF_BRIDGE_PREROUTING 0x084646+#define BRNF_8021Q 0x104747+#define BRNF_PPPoE 0x2048484949/* Only used in br_forward.c */5050extern int nf_bridge_copy_header(struct sk_buff *skb);···6666 default:6767 return 0;6868 }6969+}7070+7171+static inline unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)7272+{7373+ if (unlikely(skb->nf_bridge->mask & BRNF_PPPoE))7474+ return PPPOE_SES_HLEN;7575+ return 0;7676+}7777+7878+extern int br_handle_frame_finish(struct sk_buff *skb);7979+/* Only used in br_device.c */8080+static inline int br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)8181+{8282+ struct nf_bridge_info *nf_bridge = skb->nf_bridge;8383+8484+ skb_pull(skb, ETH_HLEN);8585+ nf_bridge->mask ^= BRNF_BRIDGED_DNAT;8686+ skb_copy_to_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN),8787+ skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);8888+ skb->dev = nf_bridge->physindev;8989+ return br_handle_frame_finish(skb);6990}70917192/* This is called by the IP fragmenting code and it ensures there is
-4
include/linux/netfilter_ipv6/ip6_tables.h
···316316extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,317317 int target, unsigned short *fragoff);318318319319-extern int ip6_masked_addrcmp(const struct in6_addr *addr1,320320- const struct in6_addr *mask,321321- const struct in6_addr *addr2);322322-323319#define IP6T_ALIGN(s) XT_ALIGN(s)324320325321#ifdef CONFIG_COMPAT
···33 * Linux ethernet bridge44 *55 * Authors:66- * Lennert Buytenhek <buytenh@gnu.org>77- * Bart De Schuymer (maintainer) <bdschuym@pandora.be>88- *99- * Changes:1010- * Apr 29 2003: physdev module support (bdschuym)1111- * Jun 19 2003: let arptables see bridged ARP traffic (bdschuym)1212- * Oct 06 2003: filter encapsulated IP/ARP VLAN traffic on untagged bridge1313- * (bdschuym)1414- * Sep 01 2004: add IPv6 filtering (bdschuym)66+ * Lennert Buytenhek <buytenh@gnu.org>77+ * Bart De Schuymer <bdschuym@pandora.be>158 *169 * This program is free software; you can redistribute it and/or1710 * modify it under the terms of the GNU General Public License···197204 skb->nf_bridge->data, header_size);198205}199206200200-/*201201- * When forwarding bridge frames, we save a copy of the original202202- * header before processing.207207+static inline void nf_bridge_update_protocol(struct sk_buff *skb)208208+{209209+ if (skb->nf_bridge->mask & BRNF_8021Q)210210+ skb->protocol = htons(ETH_P_8021Q);211211+ else if (skb->nf_bridge->mask & BRNF_PPPoE)212212+ skb->protocol = htons(ETH_P_PPP_SES);213213+}214214+215215+/* Fill in the header for fragmented IP packets handled by216216+ * the IPv4 connection tracking code.203217 */204218int nf_bridge_copy_header(struct sk_buff *skb)205219{206220 int err;207207- int header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);221221+ unsigned int header_size;208222223223+ nf_bridge_update_protocol(skb);224224+ header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);209225 err = skb_cow_head(skb, header_size);210226 if (err)211227 return err;···248246 skb_dst_set(skb, &rt->u.dst);249247250248 skb->dev = nf_bridge->physindev;249249+ nf_bridge_update_protocol(skb);251250 nf_bridge_push_encap_header(skb);252252- NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,251251+ NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,253252 br_handle_frame_finish, 1);254253255254 return 0;256255}257256258258-static void __br_dnat_complain(void)257257+/* Obtain the correct destination MAC address, while preserving the original258258+ * source MAC address. If we already know this address, we just copy it. If we259259+ * don't, we use the neighbour framework to find out. In both cases, we make260260+ * sure that br_handle_frame_finish() is called afterwards.261261+ */262262+static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)259263{260260- static unsigned long last_complaint;264264+ struct nf_bridge_info *nf_bridge = skb->nf_bridge;265265+ struct dst_entry *dst;261266262262- if (jiffies - last_complaint >= 5 * HZ) {263263- printk(KERN_WARNING "Performing cross-bridge DNAT requires IP "264264- "forwarding to be enabled\n");265265- last_complaint = jiffies;267267+ skb->dev = bridge_parent(skb->dev);268268+ if (!skb->dev)269269+ goto free_skb;270270+ dst = skb_dst(skb);271271+ if (dst->hh) {272272+ neigh_hh_bridge(dst->hh, skb);273273+ skb->dev = nf_bridge->physindev;274274+ return br_handle_frame_finish(skb);275275+ } else if (dst->neighbour) {276276+ /* the neighbour function below overwrites the complete277277+ * MAC header, so we save the Ethernet source address and278278+ * protocol number. */279279+ skb_copy_from_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN), skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);280280+ /* tell br_dev_xmit to continue with forwarding */281281+ nf_bridge->mask |= BRNF_BRIDGED_DNAT;282282+ return dst->neighbour->output(skb);266283 }284284+free_skb:285285+ kfree_skb(skb);286286+ return 0;267287}268288269289/* This requires some explaining. If DNAT has taken place,270270- * we will need to fix up the destination Ethernet address,271271- * and this is a tricky process.290290+ * we will need to fix up the destination Ethernet address.272291 *273292 * There are two cases to consider:274293 * 1. The packet was DNAT'ed to a device in the same bridge···303280 * call ip_route_input() and to look at skb->dst->dev, which is304281 * changed to the destination device if ip_route_input() succeeds.305282 *306306- * Let us first consider the case that ip_route_input() succeeds:283283+ * Let's first consider the case that ip_route_input() succeeds:307284 *308308- * If skb->dst->dev equals the logical bridge device the packet309309- * came in on, we can consider this bridging. The packet is passed310310- * through the neighbour output function to build a new destination311311- * MAC address, which will make the packet enter br_nf_local_out()312312- * not much later. In that function it is assured that the iptables313313- * FORWARD chain is traversed for the packet.314314- *285285+ * If the output device equals the logical bridge device the packet286286+ * came in on, we can consider this bridging. The corresponding MAC287287+ * address will be obtained in br_nf_pre_routing_finish_bridge.315288 * Otherwise, the packet is considered to be routed and we just316289 * change the destination MAC address so that the packet will317290 * later be passed up to the IP stack to be routed. For a redirected318291 * packet, ip_route_input() will give back the localhost as output device,319292 * which differs from the bridge device.320293 *321321- * Let us now consider the case that ip_route_input() fails:294294+ * Let's now consider the case that ip_route_input() fails:322295 *323296 * This can be because the destination address is martian, in which case324297 * the packet will be dropped.325325- * After a "echo '0' > /proc/sys/net/ipv4/ip_forward" ip_route_input()326326- * will fail, while __ip_route_output_key() will return success. The source327327- * address for __ip_route_output_key() is set to zero, so __ip_route_output_key298298+ * If IP forwarding is disabled, ip_route_input() will fail, while299299+ * ip_route_output_key() can return success. The source300300+ * address for ip_route_output_key() is set to zero, so ip_route_output_key()328301 * thinks we're handling a locally generated packet and won't care329329- * if IP forwarding is allowed. We send a warning message to the users's330330- * log telling her to put IP forwarding on.331331- *332332- * ip_route_input() will also fail if there is no route available.333333- * In that case we just drop the packet.334334- *335335- * --Lennert, 20020411336336- * --Bart, 20020416 (updated)337337- * --Bart, 20021007 (updated)338338- * --Bart, 20062711 (updated) */339339-static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)340340-{341341- if (skb->pkt_type == PACKET_OTHERHOST) {342342- skb->pkt_type = PACKET_HOST;343343- skb->nf_bridge->mask |= BRNF_PKT_TYPE;344344- }345345- skb->nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;346346-347347- skb->dev = bridge_parent(skb->dev);348348- if (skb->dev) {349349- struct dst_entry *dst = skb_dst(skb);350350-351351- nf_bridge_pull_encap_header(skb);352352-353353- if (dst->hh)354354- return neigh_hh_output(dst->hh, skb);355355- else if (dst->neighbour)356356- return dst->neighbour->output(skb);357357- }358358- kfree_skb(skb);359359- return 0;360360-}361361-302302+ * if IP forwarding is enabled. If the output device equals the logical bridge303303+ * device, we proceed as if ip_route_input() succeeded. If it differs from the304304+ * logical bridge port or if ip_route_output_key() fails we drop the packet.305305+ */362306static int br_nf_pre_routing_finish(struct sk_buff *skb)363307{364308 struct net_device *dev = skb->dev;···369379 skb_dst_set(skb, (struct dst_entry *)rt);370380 goto bridged_dnat;371381 }372372- /* we are sure that forwarding is disabled, so printing373373- * this message is no problem. Note that the packet could374374- * still have a martian destination address, in which case375375- * the packet could be dropped even if forwarding were enabled */376376- __br_dnat_complain();377382 dst_release((struct dst_entry *)rt);378383 }379384free_skb:···377392 } else {378393 if (skb_dst(skb)->dev == dev) {379394bridged_dnat:380380- /* Tell br_nf_local_out this is a381381- * bridged frame */382382- nf_bridge->mask |= BRNF_BRIDGED_DNAT;383395 skb->dev = nf_bridge->physindev;396396+ nf_bridge_update_protocol(skb);384397 nf_bridge_push_encap_header(skb);385385- NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING,398398+ NF_HOOK_THRESH(NFPROTO_BRIDGE,399399+ NF_BR_PRE_ROUTING,386400 skb, skb->dev, NULL,387401 br_nf_pre_routing_finish_bridge,388402 1);···401417 }402418403419 skb->dev = nf_bridge->physindev;420420+ nf_bridge_update_protocol(skb);404421 nf_bridge_push_encap_header(skb);405405- NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,422422+ NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,406423 br_handle_frame_finish, 1);407424408425 return 0;···422437 nf_bridge->mask |= BRNF_NF_BRIDGE_PREROUTING;423438 nf_bridge->physindev = skb->dev;424439 skb->dev = bridge_parent(skb->dev);440440+ if (skb->protocol == htons(ETH_P_8021Q))441441+ nf_bridge->mask |= BRNF_8021Q;442442+ else if (skb->protocol == htons(ETH_P_PPP_SES))443443+ nf_bridge->mask |= BRNF_PPPoE;425444426445 return skb->dev;427446}···524535 if (!setup_pre_routing(skb))525536 return NF_DROP;526537527527- NF_HOOK(PF_INET6, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,538538+ skb->protocol = htons(ETH_P_IPV6);539539+ NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,528540 br_nf_pre_routing_finish_ipv6);529541530542 return NF_STOLEN;···597607 if (!setup_pre_routing(skb))598608 return NF_DROP;599609 store_orig_dstaddr(skb);610610+ skb->protocol = htons(ETH_P_IP);600611601601- NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,612612+ NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,602613 br_nf_pre_routing_finish);603614604615 return NF_STOLEN;···646655 } else {647656 in = *((struct net_device **)(skb->cb));648657 }658658+ nf_bridge_update_protocol(skb);649659 nf_bridge_push_encap_header(skb);650650- NF_HOOK_THRESH(PF_BRIDGE, NF_BR_FORWARD, skb, in,660660+661661+ NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, in,651662 skb->dev, br_forward_finish, 1);652663 return 0;653664}···700707 /* The physdev module checks on this */701708 nf_bridge->mask |= BRNF_BRIDGED;702709 nf_bridge->physoutdev = skb->dev;710710+ if (pf == PF_INET)711711+ skb->protocol = htons(ETH_P_IP);712712+ else713713+ skb->protocol = htons(ETH_P_IPV6);703714704715 NF_HOOK(pf, NF_INET_FORWARD, skb, bridge_parent(in), parent,705716 br_nf_forward_finish);···741744 return NF_STOLEN;742745}743746744744-/* PF_BRIDGE/LOCAL_OUT ***********************************************745745- *746746- * This function sees both locally originated IP packets and forwarded747747- * IP packets (in both cases the destination device is a bridge748748- * device). It also sees bridged-and-DNAT'ed packets.749749- *750750- * If (nf_bridge->mask & BRNF_BRIDGED_DNAT) then the packet is bridged751751- * and we fake the PF_BRIDGE/FORWARD hook. The function br_nf_forward()752752- * will then fake the PF_INET/FORWARD hook. br_nf_local_out() has priority753753- * NF_BR_PRI_FIRST, so no relevant PF_BRIDGE/INPUT functions have been nor754754- * will be executed.755755- */756756-static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff *skb,757757- const struct net_device *in,758758- const struct net_device *out,759759- int (*okfn)(struct sk_buff *))760760-{761761- struct net_device *realindev;762762- struct nf_bridge_info *nf_bridge;763763-764764- if (!skb->nf_bridge)765765- return NF_ACCEPT;766766-767767- /* Need exclusive nf_bridge_info since we might have multiple768768- * different physoutdevs. */769769- if (!nf_bridge_unshare(skb))770770- return NF_DROP;771771-772772- nf_bridge = skb->nf_bridge;773773- if (!(nf_bridge->mask & BRNF_BRIDGED_DNAT))774774- return NF_ACCEPT;775775-776776- /* Bridged, take PF_BRIDGE/FORWARD.777777- * (see big note in front of br_nf_pre_routing_finish) */778778- nf_bridge->physoutdev = skb->dev;779779- realindev = nf_bridge->physindev;780780-781781- if (nf_bridge->mask & BRNF_PKT_TYPE) {782782- skb->pkt_type = PACKET_OTHERHOST;783783- nf_bridge->mask ^= BRNF_PKT_TYPE;784784- }785785- nf_bridge_push_encap_header(skb);786786-787787- NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, realindev, skb->dev,788788- br_forward_finish);789789- return NF_STOLEN;790790-}791791-792747#if defined(CONFIG_NF_CONNTRACK_IPV4) || defined(CONFIG_NF_CONNTRACK_IPV4_MODULE)793748static int br_nf_dev_queue_xmit(struct sk_buff *skb)794749{795795- if (skb->nfct != NULL &&796796- (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb)) &&797797- skb->len > skb->dev->mtu &&750750+ if (skb->nfct != NULL && skb->protocol == htons(ETH_P_IP) &&751751+ skb->len + nf_bridge_mtu_reduction(skb) > skb->dev->mtu &&798752 !skb_is_gso(skb))799753 return ip_fragment(skb, br_dev_queue_push_xmit);800754 else···768820 struct net_device *realoutdev = bridge_parent(skb->dev);769821 u_int8_t pf;770822771771-#ifdef CONFIG_NETFILTER_DEBUG772772- /* Be very paranoid. This probably won't happen anymore, but let's773773- * keep the check just to be sure... */774774- if (skb_mac_header(skb) < skb->head ||775775- skb_mac_header(skb) + ETH_HLEN > skb->data) {776776- printk(KERN_CRIT "br_netfilter: Argh!! br_nf_post_routing: "777777- "bad mac.raw pointer.\n");778778- goto print_error;779779- }780780-#endif781781-782782- if (!nf_bridge)783783- return NF_ACCEPT;784784-785785- if (!(nf_bridge->mask & (BRNF_BRIDGED | BRNF_BRIDGED_DNAT)))823823+ if (!nf_bridge || !(nf_bridge->mask & BRNF_BRIDGED))786824 return NF_ACCEPT;787825788826 if (!realoutdev)···783849 else784850 return NF_ACCEPT;785851786786-#ifdef CONFIG_NETFILTER_DEBUG787787- if (skb_dst(skb) == NULL) {788788- printk(KERN_INFO "br_netfilter post_routing: skb->dst == NULL\n");789789- goto print_error;790790- }791791-#endif792792-793852 /* We assume any code from br_dev_queue_push_xmit onwards doesn't care794853 * about the value of skb->pkt_type. */795854 if (skb->pkt_type == PACKET_OTHERHOST) {···792865793866 nf_bridge_pull_encap_header(skb);794867 nf_bridge_save_header(skb);868868+ if (pf == PF_INET)869869+ skb->protocol = htons(ETH_P_IP);870870+ else871871+ skb->protocol = htons(ETH_P_IPV6);795872796873 NF_HOOK(pf, NF_INET_POST_ROUTING, skb, NULL, realoutdev,797874 br_nf_dev_queue_xmit);798875799876 return NF_STOLEN;800800-801801-#ifdef CONFIG_NETFILTER_DEBUG802802-print_error:803803- if (skb->dev != NULL) {804804- printk("[%s]", skb->dev->name);805805- if (realoutdev)806806- printk("[%s]", realoutdev->name);807807- }808808- printk(" head:%p, raw:%p, data:%p\n", skb->head, skb_mac_header(skb),809809- skb->data);810810- dump_stack();811811- return NF_ACCEPT;812812-#endif813877}814878815879/* IP/SABOTAGE *****************************************************/···819901 return NF_ACCEPT;820902}821903822822-/* For br_nf_local_out we need (prio = NF_BR_PRI_FIRST), to insure that innocent823823- * PF_BRIDGE/NF_BR_LOCAL_OUT functions don't get bridged traffic as input.824824- * For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because825825- * ip_refrag() can return NF_STOLEN. */904904+/* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because905905+ * br_dev_queue_push_xmit is called afterwards */826906static struct nf_hook_ops br_nf_ops[] __read_mostly = {827907 {828908 .hook = br_nf_pre_routing,···849933 .pf = PF_BRIDGE,850934 .hooknum = NF_BR_FORWARD,851935 .priority = NF_BR_PRI_BRNF,852852- },853853- {854854- .hook = br_nf_local_out,855855- .owner = THIS_MODULE,856856- .pf = PF_BRIDGE,857857- .hooknum = NF_BR_LOCAL_OUT,858858- .priority = NF_BR_PRI_FIRST,859936 },860937 {861938 .hook = br_nf_post_routing,
···2727 * flushed even if it is not full yet.2828 *2929 */3030-3030+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt3131#include <linux/module.h>3232#include <linux/slab.h>3333#include <linux/spinlock.h>···4343#include <net/netfilter/nf_log.h>4444#include <net/sock.h>4545#include "../br_private.h"4646-4747-#define PRINTR(format, args...) do { if (net_ratelimit()) \4848- printk(format , ## args); } while (0)49465047static unsigned int nlbufsiz = NLMSG_GOODSIZE;5148module_param(nlbufsiz, uint, 0600);···104107 n = max(size, nlbufsiz);105108 skb = alloc_skb(n, GFP_ATOMIC);106109 if (!skb) {107107- PRINTR(KERN_ERR "ebt_ulog: can't alloc whole buffer "108108- "of size %ub!\n", n);110110+ pr_debug("cannot alloc whole buffer of size %ub!\n", n);109111 if (n > size) {110112 /* try to allocate only as much as we need for111113 * current packet */112114 skb = alloc_skb(size, GFP_ATOMIC);113115 if (!skb)114114- PRINTR(KERN_ERR "ebt_ulog: can't even allocate "115115- "buffer of size %ub\n", size);116116+ pr_debug("cannot even allocate "117117+ "buffer of size %ub\n", size);116118 }117119 }118120···138142139143 size = NLMSG_SPACE(sizeof(*pm) + copy_len);140144 if (size > nlbufsiz) {141141- PRINTR("ebt_ulog: Size %Zd needed, but nlbufsiz=%d\n",142142- size, nlbufsiz);145145+ pr_debug("Size %Zd needed, but nlbufsiz=%d\n", size, nlbufsiz);143146 return;144147 }145148···212217 return;213218214219nlmsg_failure:215215- printk(KERN_CRIT "ebt_ulog: error during NLMSG_PUT. This should "216216- "not happen, please report to author.\n");220220+ pr_debug("error during NLMSG_PUT. This should "221221+ "not happen, please report to author.\n");217222 goto unlock;218223alloc_failure:219224 goto unlock;···250255 return EBT_CONTINUE;251256}252257253253-static bool ebt_ulog_tg_check(const struct xt_tgchk_param *par)258258+static int ebt_ulog_tg_check(const struct xt_tgchk_param *par)254259{255260 struct ebt_ulog_info *uloginfo = par->targinfo;256261257262 if (uloginfo->nlgroup > 31)258258- return false;263263+ return -EINVAL;259264260265 uloginfo->prefix[EBT_ULOG_PREFIX_LEN - 1] = '\0';261266262267 if (uloginfo->qthreshold > EBT_ULOG_MAX_QLEN)263268 uloginfo->qthreshold = EBT_ULOG_MAX_QLEN;264269265265- return true;270270+ return 0;266271}267272268273static struct xt_target ebt_ulog_tg_reg __read_mostly = {···287292 int i;288293289294 if (nlbufsiz >= 128*1024) {290290- printk(KERN_NOTICE "ebt_ulog: Netlink buffer has to be <= 128kB,"291291- " please try a smaller nlbufsiz parameter.\n");295295+ pr_warning("Netlink buffer has to be <= 128kB,"296296+ " please try a smaller nlbufsiz parameter.\n");292297 return -EINVAL;293298 }294299···301306 ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG,302307 EBT_ULOG_MAXNLGROUPS, NULL, NULL,303308 THIS_MODULE);304304- if (!ebtulognl) {305305- printk(KERN_WARNING KBUILD_MODNAME ": out of memory trying to "306306- "call netlink_kernel_create\n");309309+ if (!ebtulognl)307310 ret = -ENOMEM;308308- } else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0) {311311+ else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0)309312 netlink_kernel_release(ebtulognl);310310- }311313312314 if (ret == 0)313315 nf_log_register(NFPROTO_BRIDGE, &ebt_ulog_logger);
+21-31
net/bridge/netfilter/ebt_vlan.c
···2626#include <linux/netfilter_bridge/ebtables.h>2727#include <linux/netfilter_bridge/ebt_vlan.h>28282929-static int debug;3029#define MODULE_VERS "0.6"31303232-module_param(debug, int, 0);3333-MODULE_PARM_DESC(debug, "debug=1 is turn on debug messages");3431MODULE_AUTHOR("Nick Fedchik <nick@fedchik.org.ua>");3532MODULE_DESCRIPTION("Ebtables: 802.1Q VLAN tag match");3633MODULE_LICENSE("GPL");37343838-3939-#define DEBUG_MSG(args...) if (debug) printk (KERN_DEBUG "ebt_vlan: " args)4035#define GET_BITMASK(_BIT_MASK_) info->bitmask & _BIT_MASK_4136#define EXIT_ON_MISMATCH(_MATCH_,_MASK_) {if (!((info->_MATCH_ == _MATCH_)^!!(info->invflags & _MASK_))) return false; }4237···7984 return true;8085}81868282-static bool ebt_vlan_mt_check(const struct xt_mtchk_param *par)8787+static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)8388{8489 struct ebt_vlan_info *info = par->matchinfo;8590 const struct ebt_entry *e = par->entryinfo;86918792 /* Is it 802.1Q frame checked? */8893 if (e->ethproto != htons(ETH_P_8021Q)) {8989- DEBUG_MSG9090- ("passed entry proto %2.4X is not 802.1Q (8100)\n",9191- (unsigned short) ntohs(e->ethproto));9292- return false;9494+ pr_debug("passed entry proto %2.4X is not 802.1Q (8100)\n",9595+ ntohs(e->ethproto));9696+ return -EINVAL;9397 }94989599 /* Check for bitmask range96100 * True if even one bit is out of mask */97101 if (info->bitmask & ~EBT_VLAN_MASK) {9898- DEBUG_MSG("bitmask %2X is out of mask (%2X)\n",9999- info->bitmask, EBT_VLAN_MASK);100100- return false;102102+ pr_debug("bitmask %2X is out of mask (%2X)\n",103103+ info->bitmask, EBT_VLAN_MASK);104104+ return -EINVAL;101105 }102106103107 /* Check for inversion flags range */104108 if (info->invflags & ~EBT_VLAN_MASK) {105105- DEBUG_MSG("inversion flags %2X is out of mask (%2X)\n",106106- info->invflags, EBT_VLAN_MASK);107107- return false;109109+ pr_debug("inversion flags %2X is out of mask (%2X)\n",110110+ info->invflags, EBT_VLAN_MASK);111111+ return -EINVAL;108112 }109113110114 /* Reserved VLAN ID (VID) values···115121 if (GET_BITMASK(EBT_VLAN_ID)) {116122 if (!!info->id) { /* if id!=0 => check vid range */117123 if (info->id > VLAN_GROUP_ARRAY_LEN) {118118- DEBUG_MSG119119- ("id %d is out of range (1-4096)\n",120120- info->id);121121- return false;124124+ pr_debug("id %d is out of range (1-4096)\n",125125+ info->id);126126+ return -EINVAL;122127 }123128 /* Note: This is valid VLAN-tagged frame point.124129 * Any value of user_priority are acceptable,···130137131138 if (GET_BITMASK(EBT_VLAN_PRIO)) {132139 if ((unsigned char) info->prio > 7) {133133- DEBUG_MSG("prio %d is out of range (0-7)\n",134134- info->prio);135135- return false;140140+ pr_debug("prio %d is out of range (0-7)\n",141141+ info->prio);142142+ return -EINVAL;136143 }137144 }138145 /* Check for encapsulated proto range - it is possible to be···140147 * if_ether.h: ETH_ZLEN 60 - Min. octets in frame sans FCS */141148 if (GET_BITMASK(EBT_VLAN_ENCAP)) {142149 if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) {143143- DEBUG_MSG144144- ("encap frame length %d is less than minimal\n",145145- ntohs(info->encap));146146- return false;150150+ pr_debug("encap frame length %d is less than "151151+ "minimal\n", ntohs(info->encap));152152+ return -EINVAL;147153 }148154 }149155150150- return true;156156+ return 0;151157}152158153159static struct xt_match ebt_vlan_mt_reg __read_mostly = {···161169162170static int __init ebt_vlan_init(void)163171{164164- DEBUG_MSG("ebtables 802.1Q extension module v"165165- MODULE_VERS "\n");166166- DEBUG_MSG("module debug=%d\n", !!debug);172172+ pr_debug("ebtables 802.1Q extension module v" MODULE_VERS "\n");167173 return xt_register_match(&ebt_vlan_mt_reg);168174}169175
+5-18
net/bridge/netfilter/ebtables.c
···1414 * as published by the Free Software Foundation; either version1515 * 2 of the License, or (at your option) any later version.1616 */1717-1818-1717+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1918#include <linux/kmod.h>2019#include <linux/module.h>2120#include <linux/vmalloc.h>···362363 left - sizeof(struct ebt_entry_match) < m->match_size)363364 return -EINVAL;364365365365- match = try_then_request_module(xt_find_match(NFPROTO_BRIDGE,366366- m->u.name, 0), "ebt_%s", m->u.name);366366+ match = xt_request_find_match(NFPROTO_BRIDGE, m->u.name, 0);367367 if (IS_ERR(match))368368 return PTR_ERR(match);369369- if (match == NULL)370370- return -ENOENT;371369 m->u.match = match;372370373371 par->match = match;···393397 left - sizeof(struct ebt_entry_watcher) < w->watcher_size)394398 return -EINVAL;395399396396- watcher = try_then_request_module(397397- xt_find_target(NFPROTO_BRIDGE, w->u.name, 0),398398- "ebt_%s", w->u.name);400400+ watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0);399401 if (IS_ERR(watcher))400402 return PTR_ERR(watcher);401401- if (watcher == NULL)402402- return -ENOENT;403403 w->u.watcher = watcher;404404405405 par->target = watcher;···708716 t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);709717 gap = e->next_offset - e->target_offset;710718711711- target = try_then_request_module(712712- xt_find_target(NFPROTO_BRIDGE, t->u.name, 0),713713- "ebt_%s", t->u.name);719719+ target = xt_request_find_target(NFPROTO_BRIDGE, t->u.name, 0);714720 if (IS_ERR(target)) {715721 ret = PTR_ERR(target);716716- goto cleanup_watchers;717717- } else if (target == NULL) {718718- ret = -ENOENT;719722 goto cleanup_watchers;720723 }721724···21152128 return ret;21162129 new_offset += ret;21172130 if (offsets_update && new_offset) {21182118- pr_debug("ebtables: change offset %d to %d\n",21312131+ pr_debug("change offset %d to %d\n",21192132 offsets_update[i], offsets[j] + new_offset);21202133 offsets_update[i] = offsets[j] + new_offset;21212134 }
···15991599 * not mrouter) cannot join to more than one interface - it will16001600 * result in receiving multiple packets.16011601 */16021602- NF_HOOK(PF_INET, NF_INET_FORWARD, skb, skb->dev, dev,16021602+ NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, skb, skb->dev, dev,16031603 ipmr_forward_finish);16041604 return;16051605
+12-14
net/ipv4/netfilter/arp_tables.c
···523523 return ret;524524525525 t = arpt_get_target(e);526526- target = try_then_request_module(xt_find_target(NFPROTO_ARP,527527- t->u.user.name,528528- t->u.user.revision),529529- "arpt_%s", t->u.user.name);530530- if (IS_ERR(target) || !target) {526526+ target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,527527+ t->u.user.revision);528528+ if (IS_ERR(target)) {531529 duprintf("find_check_entry: `%s' not found\n", t->u.user.name);532532- ret = target ? PTR_ERR(target) : -ENOENT;530530+ ret = PTR_ERR(target);533531 goto out;534532 }535533 t->u.kernel.target = target;···649651 if (ret != 0)650652 break;651653 ++i;654654+ if (strcmp(arpt_get_target(iter)->u.user.name,655655+ XT_ERROR_TARGET) == 0)656656+ ++newinfo->stacksize;652657 }653658 duprintf("translate_table: ARPT_ENTRY_ITERATE gives %d\n", ret);654659 if (ret != 0)···12531252 entry_offset = (void *)e - (void *)base;1254125312551254 t = compat_arpt_get_target(e);12561256- target = try_then_request_module(xt_find_target(NFPROTO_ARP,12571257- t->u.user.name,12581258- t->u.user.revision),12591259- "arpt_%s", t->u.user.name);12601260- if (IS_ERR(target) || !target) {12551255+ target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,12561256+ t->u.user.revision);12571257+ if (IS_ERR(target)) {12611258 duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",12621259 t->u.user.name);12631263- ret = target ? PTR_ERR(target) : -ENOENT;12601260+ ret = PTR_ERR(target);12641261 goto out;12651262 }12661263 t->u.kernel.target = target;···17771778{17781779 int ret;17791780 struct xt_table_info *newinfo;17801780- struct xt_table_info bootstrap17811781- = { 0, 0, 0, { 0 }, { 0 }, { } };17811781+ struct xt_table_info bootstrap = {0};17821782 void *loc_cpu_entry;17831783 struct xt_table *new_table;17841784
···161161 break;162162163163 case IPQ_COPY_PACKET:164164- if ((entry->skb->ip_summed == CHECKSUM_PARTIAL ||165165- entry->skb->ip_summed == CHECKSUM_COMPLETE) &&164164+ if (entry->skb->ip_summed == CHECKSUM_PARTIAL &&166165 (*errp = skb_checksum_help(entry->skb))) {167166 read_unlock_bh(&queue_lock);168167 return NULL;
+61-66
net/ipv4/netfilter/ip_tables.c
···3939/*#define DEBUG_IP_FIREWALL_USER*/40404141#ifdef DEBUG_IP_FIREWALL4242-#define dprintf(format, args...) printk(format , ## args)4242+#define dprintf(format, args...) pr_info(format , ## args)4343#else4444#define dprintf(format, args...)4545#endif46464747#ifdef DEBUG_IP_FIREWALL_USER4848-#define duprintf(format, args...) printk(format , ## args)4848+#define duprintf(format, args...) pr_info(format , ## args)4949#else5050#define duprintf(format, args...)5151#endif···168168ipt_error(struct sk_buff *skb, const struct xt_target_param *par)169169{170170 if (net_ratelimit())171171- printk("ip_tables: error: `%s'\n",172172- (const char *)par->targinfo);171171+ pr_info("error: `%s'\n", (const char *)par->targinfo);173172174173 return NF_DROP;175174}···321322 const struct net_device *out,322323 struct xt_table *table)323324{324324-#define tb_comefrom ((struct ipt_entry *)table_base)->comefrom325325-326325 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));327326 const struct iphdr *ip;328327 bool hotdrop = false;···328331 unsigned int verdict = NF_DROP;329332 const char *indev, *outdev;330333 const void *table_base;331331- struct ipt_entry *e, *back;334334+ struct ipt_entry *e, **jumpstack;335335+ unsigned int *stackptr, origptr, cpu;332336 const struct xt_table_info *private;333337 struct xt_match_param mtpar;334338 struct xt_target_param tgpar;···355357 IP_NF_ASSERT(table->valid_hooks & (1 << hook));356358 xt_info_rdlock_bh();357359 private = table->private;358358- table_base = private->entries[smp_processor_id()];360360+ cpu = smp_processor_id();361361+ table_base = private->entries[cpu];362362+ jumpstack = (struct ipt_entry **)private->jumpstack[cpu];363363+ stackptr = &private->stackptr[cpu];364364+ origptr = *stackptr;359365360366 e = get_entry(table_base, private->hook_entry[hook]);361367362362- /* For return from builtin chain */363363- back = get_entry(table_base, private->underflow[hook]);368368+ pr_debug("Entering %s(hook %u); sp at %u (UF %p)\n",369369+ table->name, hook, origptr,370370+ get_entry(table_base, private->underflow[hook]));364371365372 do {366373 const struct ipt_entry_target *t;367374 const struct xt_entry_match *ematch;368375369376 IP_NF_ASSERT(e);370370- IP_NF_ASSERT(back);371377 if (!ip_packet_match(ip, indev, outdev,372378 &e->ip, mtpar.fragoff)) {373379 no_match:···406404 verdict = (unsigned)(-v) - 1;407405 break;408406 }409409- e = back;410410- back = get_entry(table_base, back->comefrom);407407+ if (*stackptr == 0) {408408+ e = get_entry(table_base,409409+ private->underflow[hook]);410410+ pr_debug("Underflow (this is normal) "411411+ "to %p\n", e);412412+ } else {413413+ e = jumpstack[--*stackptr];414414+ pr_debug("Pulled %p out from pos %u\n",415415+ e, *stackptr);416416+ e = ipt_next_entry(e);417417+ }411418 continue;412419 }413420 if (table_base + v != ipt_next_entry(e) &&414421 !(e->ip.flags & IPT_F_GOTO)) {415415- /* Save old back ptr in next entry */416416- struct ipt_entry *next = ipt_next_entry(e);417417- next->comefrom = (void *)back - table_base;418418- /* set back pointer to next entry */419419- back = next;422422+ if (*stackptr >= private->stacksize) {423423+ verdict = NF_DROP;424424+ break;425425+ }426426+ jumpstack[(*stackptr)++] = e;427427+ pr_debug("Pushed %p into pos %u\n",428428+ e, *stackptr - 1);420429 }421430422431 e = get_entry(table_base, v);423432 continue;424433 }425434426426- /* Targets which reenter must return427427- abs. verdicts */428435 tgpar.target = t->u.kernel.target;429436 tgpar.targinfo = t->data;430437431438432432-#ifdef CONFIG_NETFILTER_DEBUG433433- tb_comefrom = 0xeeeeeeec;434434-#endif435439 verdict = t->u.kernel.target->target(skb, &tgpar);436436-#ifdef CONFIG_NETFILTER_DEBUG437437- if (tb_comefrom != 0xeeeeeeec && verdict == IPT_CONTINUE) {438438- printk("Target %s reentered!\n",439439- t->u.kernel.target->name);440440- verdict = NF_DROP;441441- }442442- tb_comefrom = 0x57acc001;443443-#endif444440 /* Target might have changed stuff. */445441 ip = ip_hdr(skb);446442 if (verdict == IPT_CONTINUE)···448448 break;449449 } while (!hotdrop);450450 xt_info_rdunlock_bh();451451-451451+ pr_debug("Exiting %s; resetting sp from %u to %u\n",452452+ __func__, *stackptr, origptr);453453+ *stackptr = origptr;452454#ifdef DEBUG_ALLOW_ALL453455 return NF_ACCEPT;454456#else···458456 return NF_DROP;459457 else return verdict;460458#endif461461-462462-#undef tb_comefrom463459}464460465461/* Figures out from what hook each rule can be called: returns 0 if···591591 const struct ipt_entry_target *t;592592593593 if (!ip_checkentry(&e->ip)) {594594- duprintf("ip_tables: ip check failed %p %s.\n", e, name);594594+ duprintf("ip check failed %p %s.\n", e, name);595595 return -EINVAL;596596 }597597···618618 ret = xt_check_match(par, m->u.match_size - sizeof(*m),619619 ip->proto, ip->invflags & IPT_INV_PROTO);620620 if (ret < 0) {621621- duprintf("ip_tables: check failed for `%s'.\n",622622- par.match->name);621621+ duprintf("check failed for `%s'.\n", par.match->name);623622 return ret;624623 }625624 return 0;···630631 struct xt_match *match;631632 int ret;632633633633- match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name,634634- m->u.user.revision),635635- "ipt_%s", m->u.user.name);636636- if (IS_ERR(match) || !match) {634634+ match = xt_request_find_match(NFPROTO_IPV4, m->u.user.name,635635+ m->u.user.revision);636636+ if (IS_ERR(match)) {637637 duprintf("find_check_match: `%s' not found\n", m->u.user.name);638638- return match ? PTR_ERR(match) : -ENOENT;638638+ return PTR_ERR(match);639639 }640640 m->u.kernel.match = match;641641···665667 ret = xt_check_target(&par, t->u.target_size - sizeof(*t),666668 e->ip.proto, e->ip.invflags & IPT_INV_PROTO);667669 if (ret < 0) {668668- duprintf("ip_tables: check failed for `%s'.\n",670670+ duprintf("check failed for `%s'.\n",669671 t->u.kernel.target->name);670672 return ret;671673 }···701703 }702704703705 t = ipt_get_target(e);704704- target = try_then_request_module(xt_find_target(AF_INET,705705- t->u.user.name,706706- t->u.user.revision),707707- "ipt_%s", t->u.user.name);708708- if (IS_ERR(target) || !target) {706706+ target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name,707707+ t->u.user.revision);708708+ if (IS_ERR(target)) {709709 duprintf("find_check_entry: `%s' not found\n", t->u.user.name);710710- ret = target ? PTR_ERR(target) : -ENOENT;710710+ ret = PTR_ERR(target);711711 goto cleanup_matches;712712 }713713 t->u.kernel.target = target;···839843 if (ret != 0)840844 return ret;841845 ++i;846846+ if (strcmp(ipt_get_target(iter)->u.user.name,847847+ XT_ERROR_TARGET) == 0)848848+ ++newinfo->stacksize;842849 }843850844851 if (i != repl->num_entries) {···13101311 if (ret != 0)13111312 goto free_newinfo;1312131313131313- duprintf("ip_tables: Translated table\n");13141314+ duprintf("Translated table\n");1314131513151316 ret = __do_replace(net, tmp.name, tmp.valid_hooks, newinfo,13161317 tmp.num_counters, tmp.counters);···14751476{14761477 struct xt_match *match;1477147814781478- match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name,14791479- m->u.user.revision),14801480- "ipt_%s", m->u.user.name);14811481- if (IS_ERR(match) || !match) {14791479+ match = xt_request_find_match(NFPROTO_IPV4, m->u.user.name,14801480+ m->u.user.revision);14811481+ if (IS_ERR(match)) {14821482 duprintf("compat_check_calc_match: `%s' not found\n",14831483 m->u.user.name);14841484- return match ? PTR_ERR(match) : -ENOENT;14841484+ return PTR_ERR(match);14851485 }14861486 m->u.kernel.match = match;14871487 *size += xt_compat_match_offset(match);···15471549 }1548155015491551 t = compat_ipt_get_target(e);15501550- target = try_then_request_module(xt_find_target(AF_INET,15511551- t->u.user.name,15521552- t->u.user.revision),15531553- "ipt_%s", t->u.user.name);15541554- if (IS_ERR(target) || !target) {15521552+ target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name,15531553+ t->u.user.revision);15541554+ if (IS_ERR(target)) {15551555 duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",15561556 t->u.user.name);15571557- ret = target ? PTR_ERR(target) : -ENOENT;15571557+ ret = PTR_ERR(target);15581558 goto release_matches;15591559 }15601560 t->u.kernel.target = target;···20902094{20912095 int ret;20922096 struct xt_table_info *newinfo;20932093- struct xt_table_info bootstrap20942094- = { 0, 0, 0, { 0 }, { 0 }, { } };20972097+ struct xt_table_info bootstrap = {0};20952098 void *loc_cpu_entry;20962099 struct xt_table *new_table;20972100···21792184 !!(icmpinfo->invflags&IPT_ICMP_INV));21802185}2181218621822182-static bool icmp_checkentry(const struct xt_mtchk_param *par)21872187+static int icmp_checkentry(const struct xt_mtchk_param *par)21832188{21842189 const struct ipt_icmp *icmpinfo = par->matchinfo;2185219021862191 /* Must specify no unknown invflags */21872187- return !(icmpinfo->invflags & ~IPT_ICMP_INV);21922192+ return (icmpinfo->invflags & ~IPT_ICMP_INV) ? -EINVAL : 0;21882193}2189219421902195/* The built-in targets: standard (NULL) and error. */···22712276 if (ret < 0)22722277 goto err5;2273227822742274- printk(KERN_INFO "ip_tables: (C) 2000-2006 Netfilter Core Team\n");22792279+ pr_info("(C) 2000-2006 Netfilter Core Team\n");22752280 return 0;2276228122772282err5:
+35-36
net/ipv4/netfilter/ipt_CLUSTERIP.c
···99 * published by the Free Software Foundation.1010 *1111 */1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1213#include <linux/module.h>1314#include <linux/proc_fs.h>1415#include <linux/jhash.h>···240239 break;241240 default:242241 if (net_ratelimit())243243- printk(KERN_NOTICE "CLUSTERIP: unknown protocol `%u'\n",244244- iph->protocol);242242+ pr_info("unknown protocol %u\n", iph->protocol);245243 sport = dport = 0;246244 }247245···262262 hashval = 0;263263 /* This cannot happen, unless the check function wasn't called264264 * at rule load time */265265- printk("CLUSTERIP: unknown mode `%u'\n", config->hash_mode);265265+ pr_info("unknown mode %u\n", config->hash_mode);266266 BUG();267267 break;268268 }···295295296296 ct = nf_ct_get(skb, &ctinfo);297297 if (ct == NULL) {298298- printk(KERN_ERR "CLUSTERIP: no conntrack!\n");298298+ pr_info("no conntrack!\n");299299 /* FIXME: need to drop invalid ones, since replies300300 * to outgoing connections of other nodes will be301301 * marked as INVALID */···348348 return XT_CONTINUE;349349}350350351351-static bool clusterip_tg_check(const struct xt_tgchk_param *par)351351+static int clusterip_tg_check(const struct xt_tgchk_param *par)352352{353353 struct ipt_clusterip_tgt_info *cipinfo = par->targinfo;354354 const struct ipt_entry *e = par->entryinfo;355355-356355 struct clusterip_config *config;356356+ int ret;357357358358 if (cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP &&359359 cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT &&360360 cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT_DPT) {361361- printk(KERN_WARNING "CLUSTERIP: unknown mode `%u'\n",362362- cipinfo->hash_mode);363363- return false;361361+ pr_info("unknown mode %u\n", cipinfo->hash_mode);362362+ return -EINVAL;364363365364 }366365 if (e->ip.dmsk.s_addr != htonl(0xffffffff) ||367366 e->ip.dst.s_addr == 0) {368368- printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");369369- return false;367367+ pr_info("Please specify destination IP\n");368368+ return -EINVAL;370369 }371370372371 /* FIXME: further sanity checks */···373374 config = clusterip_config_find_get(e->ip.dst.s_addr, 1);374375 if (!config) {375376 if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {376376- printk(KERN_WARNING "CLUSTERIP: no config found for %pI4, need 'new'\n", &e->ip.dst.s_addr);377377- return false;377377+ pr_info("no config found for %pI4, need 'new'\n",378378+ &e->ip.dst.s_addr);379379+ return -EINVAL;378380 } else {379381 struct net_device *dev;380382381383 if (e->ip.iniface[0] == '\0') {382382- printk(KERN_WARNING "CLUSTERIP: Please specify an interface name\n");383383- return false;384384+ pr_info("Please specify an interface name\n");385385+ return -EINVAL;384386 }385387386388 dev = dev_get_by_name(&init_net, e->ip.iniface);387389 if (!dev) {388388- printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface);389389- return false;390390+ pr_info("no such interface %s\n",391391+ e->ip.iniface);392392+ return -ENOENT;390393 }391394392395 config = clusterip_config_init(cipinfo,393396 e->ip.dst.s_addr, dev);394397 if (!config) {395395- printk(KERN_WARNING "CLUSTERIP: cannot allocate config\n");398398+ pr_info("cannot allocate config\n");396399 dev_put(dev);397397- return false;400400+ return -ENOMEM;398401 }399402 dev_mc_add(config->dev, config->clustermac);400403 }401404 }402405 cipinfo->config = config;403406404404- if (nf_ct_l3proto_try_module_get(par->target->family) < 0) {405405- printk(KERN_WARNING "can't load conntrack support for "406406- "proto=%u\n", par->target->family);407407- return false;408408- }409409-410410- return true;407407+ ret = nf_ct_l3proto_try_module_get(par->family);408408+ if (ret < 0)409409+ pr_info("cannot load conntrack support for proto=%u\n",410410+ par->family);411411+ return ret;411412}412413413414/* drop reference count of cluster config when rule is deleted */···421422422423 clusterip_config_put(cipinfo->config);423424424424- nf_ct_l3proto_module_put(par->target->family);425425+ nf_ct_l3proto_module_put(par->family);425426}426427427428#ifdef CONFIG_COMPAT···478479 }479480 hbuffer[--k]='\0';480481481481- printk("src %pI4@%s, dst %pI4\n",482482- &payload->src_ip, hbuffer, &payload->dst_ip);482482+ pr_debug("src %pI4@%s, dst %pI4\n",483483+ &payload->src_ip, hbuffer, &payload->dst_ip);483484}484485#endif485486···518519 * this wouldn't work, since we didn't subscribe the mcast group on519520 * other interfaces */520521 if (c->dev != out) {521521- pr_debug("CLUSTERIP: not mangling arp reply on different "522522+ pr_debug("not mangling arp reply on different "522523 "interface: cip'%s'-skb'%s'\n",523524 c->dev->name, out->name);524525 clusterip_config_put(c);···529530 memcpy(payload->src_hw, c->clustermac, arp->ar_hln);530531531532#ifdef DEBUG532532- pr_debug(KERN_DEBUG "CLUSTERIP mangled arp reply: ");533533+ pr_debug("mangled arp reply: ");533534 arp_print(payload);534535#endif535536···600601601602static void clusterip_seq_stop(struct seq_file *s, void *v)602603{603603- kfree(v);604604+ if (!IS_ERR(v))605605+ kfree(v);604606}605607606608static int clusterip_seq_show(struct seq_file *s, void *v)···706706#ifdef CONFIG_PROC_FS707707 clusterip_procdir = proc_mkdir("ipt_CLUSTERIP", init_net.proc_net);708708 if (!clusterip_procdir) {709709- printk(KERN_ERR "CLUSTERIP: Unable to proc dir entry\n");709709+ pr_err("Unable to proc dir entry\n");710710 ret = -ENOMEM;711711 goto cleanup_hook;712712 }713713#endif /* CONFIG_PROC_FS */714714715715- printk(KERN_NOTICE "ClusterIP Version %s loaded successfully\n",715715+ pr_info("ClusterIP Version %s loaded successfully\n",716716 CLUSTERIP_VERSION);717717 return 0;718718···727727728728static void __exit clusterip_tg_exit(void)729729{730730- printk(KERN_NOTICE "ClusterIP Version %s unloading\n",731731- CLUSTERIP_VERSION);730730+ pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);732731#ifdef CONFIG_PROC_FS733732 remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);734733#endif
+9-12
net/ipv4/netfilter/ipt_ECN.c
···66 * it under the terms of the GNU General Public License version 2 as77 * published by the Free Software Foundation.88*/99-99+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1010#include <linux/in.h>1111#include <linux/module.h>1212#include <linux/skbuff.h>···9393 return XT_CONTINUE;9494}95959696-static bool ecn_tg_check(const struct xt_tgchk_param *par)9696+static int ecn_tg_check(const struct xt_tgchk_param *par)9797{9898 const struct ipt_ECN_info *einfo = par->targinfo;9999 const struct ipt_entry *e = par->entryinfo;100100101101 if (einfo->operation & IPT_ECN_OP_MASK) {102102- printk(KERN_WARNING "ECN: unsupported ECN operation %x\n",103103- einfo->operation);104104- return false;102102+ pr_info("unsupported ECN operation %x\n", einfo->operation);103103+ return -EINVAL;105104 }106105 if (einfo->ip_ect & ~IPT_ECN_IP_MASK) {107107- printk(KERN_WARNING "ECN: new ECT codepoint %x out of mask\n",108108- einfo->ip_ect);109109- return false;106106+ pr_info("new ECT codepoint %x out of mask\n", einfo->ip_ect);107107+ return -EINVAL;110108 }111109 if ((einfo->operation & (IPT_ECN_OP_SET_ECE|IPT_ECN_OP_SET_CWR)) &&112110 (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO))) {113113- printk(KERN_WARNING "ECN: cannot use TCP operations on a "114114- "non-tcp rule\n");115115- return false;111111+ pr_info("cannot use TCP operations on a non-tcp rule\n");112112+ return -EINVAL;116113 }117117- return true;114114+ return 0;118115}119116120117static struct xt_target ecn_tg_reg __read_mostly = {
+8-9
net/ipv4/netfilter/ipt_LOG.c
···99 * it under the terms of the GNU General Public License version 2 as1010 * published by the Free Software Foundation.1111 */1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/module.h>1414#include <linux/spinlock.h>1515#include <linux/skbuff.h>···367367 .type = NF_LOG_TYPE_LOG,368368 .u = {369369 .log = {370370- .level = 0,370370+ .level = 5,371371 .logflags = NF_LOG_MASK,372372 },373373 },···439439 return XT_CONTINUE;440440}441441442442-static bool log_tg_check(const struct xt_tgchk_param *par)442442+static int log_tg_check(const struct xt_tgchk_param *par)443443{444444 const struct ipt_log_info *loginfo = par->targinfo;445445446446 if (loginfo->level >= 8) {447447- pr_debug("LOG: level %u >= 8\n", loginfo->level);448448- return false;447447+ pr_debug("level %u >= 8\n", loginfo->level);448448+ return -EINVAL;449449 }450450 if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') {451451- pr_debug("LOG: prefix term %i\n",452452- loginfo->prefix[sizeof(loginfo->prefix)-1]);453453- return false;451451+ pr_debug("prefix is not null-terminated\n");452452+ return -EINVAL;454453 }455455- return true;454454+ return 0;456455}457456458457static struct xt_target log_tg_reg __read_mostly = {
+8-8
net/ipv4/netfilter/ipt_MASQUERADE.c
···88 * it under the terms of the GNU General Public License version 2 as99 * published by the Free Software Foundation.1010 */1111-1111+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1212#include <linux/types.h>1313#include <linux/inetdevice.h>1414#include <linux/ip.h>···2828MODULE_DESCRIPTION("Xtables: automatic-address SNAT");29293030/* FIXME: Multiple targets. --RR */3131-static bool masquerade_tg_check(const struct xt_tgchk_param *par)3131+static int masquerade_tg_check(const struct xt_tgchk_param *par)3232{3333 const struct nf_nat_multi_range_compat *mr = par->targinfo;34343535 if (mr->range[0].flags & IP_NAT_RANGE_MAP_IPS) {3636- pr_debug("masquerade_check: bad MAP_IPS.\n");3737- return false;3636+ pr_debug("bad MAP_IPS.\n");3737+ return -EINVAL;3838 }3939 if (mr->rangesize != 1) {4040- pr_debug("masquerade_check: bad rangesize %u\n", mr->rangesize);4141- return false;4040+ pr_debug("bad rangesize %u\n", mr->rangesize);4141+ return -EINVAL;4242 }4343- return true;4343+ return 0;4444}45454646static unsigned int···7272 rt = skb_rtable(skb);7373 newsrc = inet_select_addr(par->out, rt->rt_gateway, RT_SCOPE_UNIVERSE);7474 if (!newsrc) {7575- printk("MASQUERADE: %s ate my IP address\n", par->out->name);7575+ pr_info("%s ate my IP address\n", par->out->name);7676 return NF_DROP;7777 }7878
+7-7
net/ipv4/netfilter/ipt_NETMAP.c
···99 * it under the terms of the GNU General Public License version 2 as1010 * published by the Free Software Foundation.1111 */1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/ip.h>1414#include <linux/module.h>1515#include <linux/netdevice.h>···2222MODULE_AUTHOR("Svenning Soerensen <svenning@post5.tele.dk>");2323MODULE_DESCRIPTION("Xtables: 1:1 NAT mapping of IPv4 subnets");24242525-static bool netmap_tg_check(const struct xt_tgchk_param *par)2525+static int netmap_tg_check(const struct xt_tgchk_param *par)2626{2727 const struct nf_nat_multi_range_compat *mr = par->targinfo;28282929 if (!(mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)) {3030- pr_debug("NETMAP:check: bad MAP_IPS.\n");3131- return false;3030+ pr_debug("bad MAP_IPS.\n");3131+ return -EINVAL;3232 }3333 if (mr->rangesize != 1) {3434- pr_debug("NETMAP:check: bad rangesize %u.\n", mr->rangesize);3535- return false;3434+ pr_debug("bad rangesize %u.\n", mr->rangesize);3535+ return -EINVAL;3636 }3737- return true;3737+ return 0;3838}39394040static unsigned int
+7-7
net/ipv4/netfilter/ipt_REDIRECT.c
···66 * it under the terms of the GNU General Public License version 2 as77 * published by the Free Software Foundation.88 */99-99+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1010#include <linux/types.h>1111#include <linux/ip.h>1212#include <linux/timer.h>···2626MODULE_DESCRIPTION("Xtables: Connection redirection to localhost");27272828/* FIXME: Take multiple ranges --RR */2929-static bool redirect_tg_check(const struct xt_tgchk_param *par)2929+static int redirect_tg_check(const struct xt_tgchk_param *par)3030{3131 const struct nf_nat_multi_range_compat *mr = par->targinfo;32323333 if (mr->range[0].flags & IP_NAT_RANGE_MAP_IPS) {3434- pr_debug("redirect_check: bad MAP_IPS.\n");3535- return false;3434+ pr_debug("bad MAP_IPS.\n");3535+ return -EINVAL;3636 }3737 if (mr->rangesize != 1) {3838- pr_debug("redirect_check: bad rangesize %u.\n", mr->rangesize);3939- return false;3838+ pr_debug("bad rangesize %u.\n", mr->rangesize);3939+ return -EINVAL;4040 }4141- return true;4141+ return 0;4242}43434444static unsigned int
+7-10
net/ipv4/netfilter/ipt_REJECT.c
···99 * it under the terms of the GNU General Public License version 2 as1010 * published by the Free Software Foundation.1111 */1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/module.h>1414#include <linux/skbuff.h>1515#include <linux/slab.h>···140140{141141 const struct ipt_reject_info *reject = par->targinfo;142142143143- /* WARNING: This code causes reentry within iptables.144144- This means that the iptables jump stack is now crap. We145145- must return an absolute verdict. --RR */146143 switch (reject->with) {147144 case IPT_ICMP_NET_UNREACHABLE:148145 send_unreach(skb, ICMP_NET_UNREACH);···172175 return NF_DROP;173176}174177175175-static bool reject_tg_check(const struct xt_tgchk_param *par)178178+static int reject_tg_check(const struct xt_tgchk_param *par)176179{177180 const struct ipt_reject_info *rejinfo = par->targinfo;178181 const struct ipt_entry *e = par->entryinfo;179182180183 if (rejinfo->with == IPT_ICMP_ECHOREPLY) {181181- printk("ipt_REJECT: ECHOREPLY no longer supported.\n");182182- return false;184184+ pr_info("ECHOREPLY no longer supported.\n");185185+ return -EINVAL;183186 } else if (rejinfo->with == IPT_TCP_RESET) {184187 /* Must specify that it's a TCP packet */185188 if (e->ip.proto != IPPROTO_TCP ||186189 (e->ip.invflags & XT_INV_PROTO)) {187187- printk("ipt_REJECT: TCP_RESET invalid for non-tcp\n");188188- return false;190190+ pr_info("TCP_RESET invalid for non-tcp\n");191191+ return -EINVAL;189192 }190193 }191191- return true;194194+ return 0;192195}193196194197static struct xt_target reject_tg_reg __read_mostly = {
+19-26
net/ipv4/netfilter/ipt_ULOG.c
···2929 * Specify, after how many hundredths of a second the queue should be3030 * flushed even if it is not full yet.3131 */3232-3232+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt3333#include <linux/module.h>3434#include <linux/spinlock.h>3535#include <linux/socket.h>···56565757#define ULOG_NL_EVENT 111 /* Harald's favorite number */5858#define ULOG_MAXNLGROUPS 32 /* numer of nlgroups */5959-6060-#define PRINTR(format, args...) do { if (net_ratelimit()) printk(format , ## args); } while (0)61596260static unsigned int nlbufsiz = NLMSG_GOODSIZE;6361module_param(nlbufsiz, uint, 0400);···8991 ulog_buff_t *ub = &ulog_buffers[nlgroupnum];90929193 if (timer_pending(&ub->timer)) {9292- pr_debug("ipt_ULOG: ulog_send: timer was pending, deleting\n");9494+ pr_debug("ulog_send: timer was pending, deleting\n");9395 del_timer(&ub->timer);9496 }95979698 if (!ub->skb) {9797- pr_debug("ipt_ULOG: ulog_send: nothing to send\n");9999+ pr_debug("ulog_send: nothing to send\n");98100 return;99101 }100102···103105 ub->lastnlh->nlmsg_type = NLMSG_DONE;104106105107 NETLINK_CB(ub->skb).dst_group = nlgroupnum + 1;106106- pr_debug("ipt_ULOG: throwing %d packets to netlink group %u\n",108108+ pr_debug("throwing %d packets to netlink group %u\n",107109 ub->qlen, nlgroupnum + 1);108110 netlink_broadcast(nflognl, ub->skb, 0, nlgroupnum + 1, GFP_ATOMIC);109111···116118/* timer function to flush queue in flushtimeout time */117119static void ulog_timer(unsigned long data)118120{119119- pr_debug("ipt_ULOG: timer function called, calling ulog_send\n");121121+ pr_debug("timer function called, calling ulog_send\n");120122121123 /* lock to protect against somebody modifying our structure122124 * from ipt_ulog_target at the same time */···137139 n = max(size, nlbufsiz);138140 skb = alloc_skb(n, GFP_ATOMIC);139141 if (!skb) {140140- PRINTR("ipt_ULOG: can't alloc whole buffer %ub!\n", n);142142+ pr_debug("cannot alloc whole buffer %ub!\n", n);141143142144 if (n > size) {143145 /* try to allocate only as much as we need for···145147146148 skb = alloc_skb(size, GFP_ATOMIC);147149 if (!skb)148148- PRINTR("ipt_ULOG: can't even allocate %ub\n",149149- size);150150+ pr_debug("cannot even allocate %ub\n", size);150151 }151152 }152153···196199 goto alloc_failure;197200 }198201199199- pr_debug("ipt_ULOG: qlen %d, qthreshold %Zu\n", ub->qlen,200200- loginfo->qthreshold);202202+ pr_debug("qlen %d, qthreshold %Zu\n", ub->qlen, loginfo->qthreshold);201203202204 /* NLMSG_PUT contains a hidden goto nlmsg_failure !!! */203205 nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT,···269273 return;270274271275nlmsg_failure:272272- PRINTR("ipt_ULOG: error during NLMSG_PUT\n");273273-276276+ pr_debug("error during NLMSG_PUT\n");274277alloc_failure:275275- PRINTR("ipt_ULOG: Error building netlink message\n");276276-278278+ pr_debug("Error building netlink message\n");277279 spin_unlock_bh(&ulog_lock);278280}279281···308314 ipt_ulog_packet(hooknum, skb, in, out, &loginfo, prefix);309315}310316311311-static bool ulog_tg_check(const struct xt_tgchk_param *par)317317+static int ulog_tg_check(const struct xt_tgchk_param *par)312318{313319 const struct ipt_ulog_info *loginfo = par->targinfo;314320315321 if (loginfo->prefix[sizeof(loginfo->prefix) - 1] != '\0') {316316- pr_debug("ipt_ULOG: prefix term %i\n",317317- loginfo->prefix[sizeof(loginfo->prefix) - 1]);318318- return false;322322+ pr_debug("prefix not null-terminated\n");323323+ return -EINVAL;319324 }320325 if (loginfo->qthreshold > ULOG_MAX_QLEN) {321321- pr_debug("ipt_ULOG: queue threshold %Zu > MAX_QLEN\n",326326+ pr_debug("queue threshold %Zu > MAX_QLEN\n",322327 loginfo->qthreshold);323323- return false;328328+ return -EINVAL;324329 }325325- return true;330330+ return 0;326331}327332328333#ifdef CONFIG_COMPAT···383390{384391 int ret, i;385392386386- pr_debug("ipt_ULOG: init module\n");393393+ pr_debug("init module\n");387394388395 if (nlbufsiz > 128*1024) {389389- printk("Netlink buffer has to be <= 128kB\n");396396+ pr_warning("Netlink buffer has to be <= 128kB\n");390397 return -EINVAL;391398 }392399···416423 ulog_buff_t *ub;417424 int i;418425419419- pr_debug("ipt_ULOG: cleanup_module\n");426426+ pr_debug("cleanup_module\n");420427421428 if (nflog)422429 nf_log_unregister(&ipt_ulog_logger);
+12-12
net/ipv4/netfilter/ipt_addrtype.c
···88 * it under the terms of the GNU General Public License version 2 as99 * published by the Free Software Foundation.1010 */1111-1111+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1212#include <linux/kernel.h>1313#include <linux/module.h>1414#include <linux/skbuff.h>···7070 return ret;7171}72727373-static bool addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par)7373+static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par)7474{7575 struct ipt_addrtype_info_v1 *info = par->matchinfo;76767777 if (info->flags & IPT_ADDRTYPE_LIMIT_IFACE_IN &&7878 info->flags & IPT_ADDRTYPE_LIMIT_IFACE_OUT) {7979- printk(KERN_ERR "ipt_addrtype: both incoming and outgoing "8080- "interface limitation cannot be selected\n");8181- return false;7979+ pr_info("both incoming and outgoing "8080+ "interface limitation cannot be selected\n");8181+ return -EINVAL;8282 }83838484 if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) |8585 (1 << NF_INET_LOCAL_IN)) &&8686 info->flags & IPT_ADDRTYPE_LIMIT_IFACE_OUT) {8787- printk(KERN_ERR "ipt_addrtype: output interface limitation "8888- "not valid in PRE_ROUTING and INPUT\n");8989- return false;8787+ pr_info("output interface limitation "8888+ "not valid in PREROUTING and INPUT\n");8989+ return -EINVAL;9090 }91919292 if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) |9393 (1 << NF_INET_LOCAL_OUT)) &&9494 info->flags & IPT_ADDRTYPE_LIMIT_IFACE_IN) {9595- printk(KERN_ERR "ipt_addrtype: input interface limitation "9696- "not valid in POST_ROUTING and OUTPUT\n");9797- return false;9595+ pr_info("input interface limitation "9696+ "not valid in POSTROUTING and OUTPUT\n");9797+ return -EINVAL;9898 }9999100100- return true;100100+ return 0;101101}102102103103static struct xt_match addrtype_mt_reg[] __read_mostly = {
+9-15
net/ipv4/netfilter/ipt_ah.c
···55 * it under the terms of the GNU General Public License version 2 as66 * published by the Free Software Foundation.77 */88-88+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt99#include <linux/in.h>1010#include <linux/module.h>1111#include <linux/skbuff.h>···1818MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");1919MODULE_DESCRIPTION("Xtables: IPv4 IPsec-AH SPI match");20202121-#ifdef DEBUG_CONNTRACK2222-#define duprintf(format, args...) printk(format , ## args)2323-#else2424-#define duprintf(format, args...)2525-#endif2626-2721/* Returns 1 if the spi is matched by the range, 0 otherwise */2822static inline bool2923spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, bool invert)3024{3125 bool r;3232- duprintf("ah spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',3333- min,spi,max);2626+ pr_debug("spi_match:%c 0x%x <= 0x%x <= 0x%x\n",2727+ invert ? '!' : ' ', min, spi, max);3428 r=(spi >= min && spi <= max) ^ invert;3535- duprintf(" result %s\n",r? "PASS" : "FAILED");2929+ pr_debug(" result %s\n", r ? "PASS" : "FAILED");3630 return r;3731}3832···4551 /* We've been asked to examine this packet, and we4652 * can't. Hence, no choice but to drop.4753 */4848- duprintf("Dropping evil AH tinygram.\n");5454+ pr_debug("Dropping evil AH tinygram.\n");4955 *par->hotdrop = true;5056 return 0;5157 }···5561 !!(ahinfo->invflags & IPT_AH_INV_SPI));5662}57635858-static bool ah_mt_check(const struct xt_mtchk_param *par)6464+static int ah_mt_check(const struct xt_mtchk_param *par)5965{6066 const struct ipt_ah *ahinfo = par->matchinfo;61676268 /* Must specify no unknown invflags */6369 if (ahinfo->invflags & ~IPT_AH_INV_MASK) {6464- duprintf("ipt_ah: unknown flags %X\n", ahinfo->invflags);6565- return false;7070+ pr_debug("unknown flags %X\n", ahinfo->invflags);7171+ return -EINVAL;6672 }6767- return true;7373+ return 0;6874}69757076static struct xt_match ah_mt_reg __read_mostly = {
+7-8
net/ipv4/netfilter/ipt_ecn.c
···66 * it under the terms of the GNU General Public License version 2 as77 * published by the Free Software Foundation.88 */99-99+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1010#include <linux/in.h>1111#include <linux/ip.h>1212#include <net/ip.h>···8585 return true;8686}87878888-static bool ecn_mt_check(const struct xt_mtchk_param *par)8888+static int ecn_mt_check(const struct xt_mtchk_param *par)8989{9090 const struct ipt_ecn_info *info = par->matchinfo;9191 const struct ipt_ip *ip = par->entryinfo;92929393 if (info->operation & IPT_ECN_OP_MATCH_MASK)9494- return false;9494+ return -EINVAL;95959696 if (info->invert & IPT_ECN_OP_MATCH_MASK)9797- return false;9797+ return -EINVAL;98989999 if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR) &&100100 ip->proto != IPPROTO_TCP) {101101- printk(KERN_WARNING "ipt_ecn: can't match TCP bits in rule for"102102- " non-tcp packets\n");103103- return false;101101+ pr_info("cannot match TCP bits in rule for non-tcp packets\n");102102+ return -EINVAL;104103 }105104106106- return true;105105+ return 0;107106}108107109108static struct xt_match ecn_mt_reg __read_mostly = {
···314314315315if NETFILTER_XTABLES316316317317+comment "Xtables combined modules"318318+319319+config NETFILTER_XT_MARK320320+ tristate 'nfmark target and match support'321321+ default m if NETFILTER_ADVANCED=n322322+ ---help---323323+ This option adds the "MARK" target and "mark" match.324324+325325+ Netfilter mark matching allows you to match packets based on the326326+ "nfmark" value in the packet.327327+ The target allows you to create rules in the "mangle" table which alter328328+ the netfilter mark (nfmark) field associated with the packet.329329+330330+ Prior to routing, the nfmark can influence the routing method (see331331+ "Use netfilter MARK value as routing key") and can also be used by332332+ other subsystems to change their behavior.333333+334334+config NETFILTER_XT_CONNMARK335335+ tristate 'ctmark target and match support'336336+ depends on NF_CONNTRACK337337+ depends on NETFILTER_ADVANCED338338+ select NF_CONNTRACK_MARK339339+ ---help---340340+ This option adds the "CONNMARK" target and "connmark" match.341341+342342+ Netfilter allows you to store a mark value per connection (a.k.a.343343+ ctmark), similarly to the packet mark (nfmark). Using this344344+ target and match, you can set and match on this mark.345345+317346# alphabetically ordered list of targets347347+348348+comment "Xtables targets"318349319350config NETFILTER_XT_TARGET_CLASSIFY320351 tristate '"CLASSIFY" target support'···363332 tristate '"CONNMARK" target support'364333 depends on NF_CONNTRACK365334 depends on NETFILTER_ADVANCED366366- select NF_CONNTRACK_MARK367367- help368368- This option adds a `CONNMARK' target, which allows one to manipulate369369- the connection mark value. Similar to the MARK target, but370370- affects the connection mark value rather than the packet mark value.371371-372372- If you want to compile it as a module, say M here and read373373- <file:Documentation/kbuild/modules.txt>. The module will be called374374- ipt_CONNMARK. If unsure, say `N'.335335+ select NETFILTER_XT_CONNMARK336336+ ---help---337337+ This is a backwards-compat option for the user's convenience338338+ (e.g. when running oldconfig). It selects339339+ CONFIG_NETFILTER_XT_CONNMARK (combined connmark/CONNMARK module).375340376341config NETFILTER_XT_TARGET_CONNSECMARK377342 tristate '"CONNSECMARK" target support'···450423451424config NETFILTER_XT_TARGET_MARK452425 tristate '"MARK" target support'453453- default m if NETFILTER_ADVANCED=n454454- help455455- This option adds a `MARK' target, which allows you to create rules456456- in the `mangle' table which alter the netfilter mark (nfmark) field457457- associated with the packet prior to routing. This can change458458- the routing method (see `Use netfilter MARK value as routing459459- key') and can also be used by other subsystems to change their460460- behavior.461461-462462- To compile it as a module, choose M here. If unsure, say N.426426+ depends on NETFILTER_ADVANCED427427+ select NETFILTER_XT_MARK428428+ ---help---429429+ This is a backwards-compat option for the user's convenience430430+ (e.g. when running oldconfig). It selects431431+ CONFIG_NETFILTER_XT_MARK (combined mark/MARK module).463432464433config NETFILTER_XT_TARGET_NFLOG465434 tristate '"NFLOG" target support'···501478 used to match on the measured rates.502479503480 To compile it as a module, choose M here. If unsure, say N.481481+482482+config NETFILTER_XT_TARGET_TEE483483+ tristate '"TEE" - packet cloning to alternate destiantion'484484+ depends on NETFILTER_ADVANCED485485+ ---help---486486+ This option adds a "TEE" target with which a packet can be cloned and487487+ this clone be rerouted to another nexthop.504488505489config NETFILTER_XT_TARGET_TPROXY506490 tristate '"TPROXY" target support (EXPERIMENTAL)'···582552 This option adds a "TCPOPTSTRIP" target, which allows you to strip583553 TCP options from TCP packets.584554555555+# alphabetically ordered list of matches556556+557557+comment "Xtables matches"558558+585559config NETFILTER_XT_MATCH_CLUSTER586560 tristate '"cluster" match support'587561 depends on NF_CONNTRACK···636602 tristate '"connmark" connection mark match support'637603 depends on NF_CONNTRACK638604 depends on NETFILTER_ADVANCED639639- select NF_CONNTRACK_MARK640640- help641641- This option adds a `connmark' match, which allows you to match the642642- connection mark value previously set for the session by `CONNMARK'. 643643-644644- If you want to compile it as a module, say M here and read645645- <file:Documentation/kbuild/modules.txt>. The module will be called646646- ipt_connmark. If unsure, say `N'.605605+ select NETFILTER_XT_CONNMARK606606+ ---help---607607+ This is a backwards-compat option for the user's convenience608608+ (e.g. when running oldconfig). It selects609609+ CONFIG_NETFILTER_XT_CONNMARK (combined connmark/CONNMARK module).647610648611config NETFILTER_XT_MATCH_CONNTRACK649612 tristate '"conntrack" connection tracking match support'···764733765734config NETFILTER_XT_MATCH_MARK766735 tristate '"mark" match support'767767- default m if NETFILTER_ADVANCED=n768768- help769769- Netfilter mark matching allows you to match packets based on the770770- `nfmark' value in the packet. This can be set by the MARK target771771- (see below).772772-773773- To compile it as a module, choose M here. If unsure, say N.736736+ depends on NETFILTER_ADVANCED737737+ select NETFILTER_XT_MARK738738+ ---help---739739+ This is a backwards-compat option for the user's convenience740740+ (e.g. when running oldconfig). It selects741741+ CONFIG_NETFILTER_XT_MARK (combined mark/MARK module).774742775743config NETFILTER_XT_MATCH_MULTIPORT776744 tristate '"multiport" Multiple port match support'···778748 Multiport matching allows you to match TCP or UDP packets based on779749 a series of source or destination ports: normally a rule can only780750 match a single range of ports.751751+752752+ To compile it as a module, choose M here. If unsure, say N.753753+754754+config NETFILTER_XT_MATCH_OSF755755+ tristate '"osf" Passive OS fingerprint match'756756+ depends on NETFILTER_ADVANCED && NETFILTER_NETLINK757757+ help758758+ This option selects the Passive OS Fingerprinting match module759759+ that allows to passively match the remote operating system by760760+ analyzing incoming TCP SYN packets.761761+762762+ Rules and loading software can be downloaded from763763+ http://www.ioremap.net/projects/osf781764782765 To compile it as a module, choose M here. If unsure, say N.783766···878835879836 Short options are available by using 'iptables -m recent -h'880837 Official Website: <http://snowman.net/projects/ipt_recent/>881881-882882-config NETFILTER_XT_MATCH_RECENT_PROC_COMPAT883883- bool 'Enable obsolete /proc/net/ipt_recent'884884- depends on NETFILTER_XT_MATCH_RECENT && PROC_FS885885- ---help---886886- This option enables the old /proc/net/ipt_recent interface,887887- which has been obsoleted by /proc/net/xt_recent.888838889839config NETFILTER_XT_MATCH_SCTP890840 tristate '"sctp" protocol match support (EXPERIMENTAL)'···977941 lengths.978942979943 Details and examples are in the kernel module source.980980-981981-config NETFILTER_XT_MATCH_OSF982982- tristate '"osf" Passive OS fingerprint match'983983- depends on NETFILTER_ADVANCED && NETFILTER_NETLINK984984- help985985- This option selects the Passive OS Fingerprinting match module986986- that allows to passively match the remote operating system by987987- analyzing incoming TCP SYN packets.988988-989989- Rules and loading software can be downloaded from990990- http://www.ioremap.net/projects/osf991991-992992- To compile it as a module, choose M here. If unsure, say N.993944994945endif # NETFILTER_XTABLES995946
···319319 * not the expected one, we must restart lookup.320320 * We probably met an item that was moved to another chain.321321 */322322- if (get_nulls_value(n) != hash)322322+ if (get_nulls_value(n) != hash) {323323+ NF_CT_STAT_INC(net, search_restart);323324 goto begin;325325+ }324326 local_bh_enable();325327326328 return NULL;
···1414#include <linux/module.h>1515#include <linux/slab.h>1616#include <linux/mutex.h>1717-#include <linux/skbuff.h>1817#include <linux/vmalloc.h>1918#include <linux/stddef.h>2019#include <linux/err.h>2120#include <linux/percpu.h>2222-#include <linux/moduleparam.h>2321#include <linux/notifier.h>2422#include <linux/kernel.h>2523#include <linux/netdevice.h>···117119{118120 struct nf_conntrack_l3proto *p;119121120120- /* rcu_read_lock not necessary since the caller holds a reference */122122+ /* rcu_read_lock not necessary since the caller holds a reference, but123123+ * taken anyways to avoid lockdep warnings in __nf_ct_l3proto_find()124124+ */125125+ rcu_read_lock();121126 p = __nf_ct_l3proto_find(l3proto);122127 module_put(p->me);128128+ rcu_read_unlock();123129}124130EXPORT_SYMBOL_GPL(nf_ct_l3proto_module_put);125131
···1515 * published by the Free Software Foundation.1616 *1717 */1818+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1819#include <linux/module.h>1920#include <linux/skbuff.h>2021#include <linux/netfilter/x_tables.h>2122#include <linux/netfilter/xt_CONNSECMARK.h>2223#include <net/netfilter/nf_conntrack.h>2324#include <net/netfilter/nf_conntrack_ecache.h>2424-2525-#define PFX "CONNSECMARK: "26252726MODULE_LICENSE("GPL");2827MODULE_AUTHOR("James Morris <jmorris@redhat.com>");···8485 return XT_CONTINUE;8586}86878787-static bool connsecmark_tg_check(const struct xt_tgchk_param *par)8888+static int connsecmark_tg_check(const struct xt_tgchk_param *par)8889{8990 const struct xt_connsecmark_target_info *info = par->targinfo;9191+ int ret;90929193 if (strcmp(par->table, "mangle") != 0 &&9294 strcmp(par->table, "security") != 0) {9393- printk(KERN_INFO PFX "target only valid in the \'mangle\' "9494- "or \'security\' tables, not \'%s\'.\n", par->table);9595- return false;9595+ pr_info("target only valid in the \'mangle\' "9696+ "or \'security\' tables, not \'%s\'.\n", par->table);9797+ return -EINVAL;9698 }979998100 switch (info->mode) {···102102 break;103103104104 default:105105- printk(KERN_INFO PFX "invalid mode: %hu\n", info->mode);106106- return false;105105+ pr_info("invalid mode: %hu\n", info->mode);106106+ return -EINVAL;107107 }108108109109- if (nf_ct_l3proto_try_module_get(par->family) < 0) {110110- printk(KERN_WARNING "can't load conntrack support for "111111- "proto=%u\n", par->family);112112- return false;113113- }114114- return true;109109+ ret = nf_ct_l3proto_try_module_get(par->family);110110+ if (ret < 0)111111+ pr_info("cannot load conntrack support for proto=%u\n",112112+ par->family);113113+ return ret;115114}116115117116static void connsecmark_tg_destroy(const struct xt_tgdtor_param *par)
+15-8
net/netfilter/xt_CT.c
···38383939static u8 xt_ct_find_proto(const struct xt_tgchk_param *par)4040{4141- if (par->family == AF_INET) {4141+ if (par->family == NFPROTO_IPV4) {4242 const struct ipt_entry *e = par->entryinfo;43434444 if (e->ip.invflags & IPT_INV_PROTO)4545 return 0;4646 return e->ip.proto;4747- } else if (par->family == AF_INET6) {4747+ } else if (par->family == NFPROTO_IPV6) {4848 const struct ip6t_entry *e = par->entryinfo;49495050 if (e->ipv6.invflags & IP6T_INV_PROTO)···5454 return 0;5555}56565757-static bool xt_ct_tg_check(const struct xt_tgchk_param *par)5757+static int xt_ct_tg_check(const struct xt_tgchk_param *par)5858{5959 struct xt_ct_target_info *info = par->targinfo;6060 struct nf_conntrack_tuple t;6161 struct nf_conn_help *help;6262 struct nf_conn *ct;6363+ int ret = 0;6364 u8 proto;64656566 if (info->flags & ~XT_CT_NOTRACK)6666- return false;6767+ return -EINVAL;67686869 if (info->flags & XT_CT_NOTRACK) {6970 ct = &nf_conntrack_untracked;···7776 goto err1;7877#endif79788080- if (nf_ct_l3proto_try_module_get(par->family) < 0)7979+ ret = nf_ct_l3proto_try_module_get(par->family);8080+ if (ret < 0)8181 goto err1;82828383 memset(&t, 0, sizeof(t));8484 ct = nf_conntrack_alloc(par->net, info->zone, &t, &t, GFP_KERNEL);8585+ ret = PTR_ERR(ct);8586 if (IS_ERR(ct))8687 goto err2;87888989+ ret = 0;8890 if ((info->ct_events || info->exp_events) &&8991 !nf_ct_ecache_ext_add(ct, info->ct_events, info->exp_events,9092 GFP_KERNEL))9193 goto err3;92949395 if (info->helper[0]) {9696+ ret = -ENOENT;9497 proto = xt_ct_find_proto(par);9598 if (!proto)9699 goto err3;97100101101+ ret = -ENOMEM;98102 help = nf_ct_helper_ext_add(ct, GFP_KERNEL);99103 if (help == NULL)100104 goto err3;101105106106+ ret = -ENOENT;102107 help->helper = nf_conntrack_helper_try_module_get(info->helper,103108 par->family,104109 proto);···116109 __set_bit(IPS_CONFIRMED_BIT, &ct->status);117110out:118111 info->ct = ct;119119- return true;112112+ return 0;120113121114err3:122115 nf_conntrack_free(ct);123116err2:124117 nf_ct_l3proto_module_put(par->family);125118err1:126126- return false;119119+ return ret;127120}128121129122static void xt_ct_tg_destroy(const struct xt_tgdtor_param *par)···145138static struct xt_target xt_ct_tg __read_mostly = {146139 .name = "CT",147140 .family = NFPROTO_UNSPEC,148148- .targetsize = XT_ALIGN(sizeof(struct xt_ct_target_info)),141141+ .targetsize = sizeof(struct xt_ct_target_info),149142 .checkentry = xt_ct_tg_check,150143 .destroy = xt_ct_tg_destroy,151144 .target = xt_ct_target,
+5-5
net/netfilter/xt_DSCP.c
···99 *1010 * See RFC2474 for a description of the DSCP field within the IP Header.1111*/1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/module.h>1414#include <linux/skbuff.h>1515#include <linux/ip.h>···6060 return XT_CONTINUE;6161}62626363-static bool dscp_tg_check(const struct xt_tgchk_param *par)6363+static int dscp_tg_check(const struct xt_tgchk_param *par)6464{6565 const struct xt_DSCP_info *info = par->targinfo;66666767 if (info->dscp > XT_DSCP_MAX) {6868- printk(KERN_WARNING "DSCP: dscp %x out of range\n", info->dscp);6969- return false;6868+ pr_info("dscp %x out of range\n", info->dscp);6969+ return -EDOM;7070 }7171- return true;7171+ return 0;7272}73737474static unsigned int
+12-14
net/netfilter/xt_HL.c
···99 * it under the terms of the GNU General Public License version 2 as1010 * published by the Free Software Foundation.1111 */1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/module.h>1414#include <linux/skbuff.h>1515#include <linux/ip.h>···101101 return XT_CONTINUE;102102}103103104104-static bool ttl_tg_check(const struct xt_tgchk_param *par)104104+static int ttl_tg_check(const struct xt_tgchk_param *par)105105{106106 const struct ipt_TTL_info *info = par->targinfo;107107108108 if (info->mode > IPT_TTL_MAXMODE) {109109- printk(KERN_WARNING "ipt_TTL: invalid or unknown Mode %u\n",110110- info->mode);111111- return false;109109+ pr_info("TTL: invalid or unknown mode %u\n", info->mode);110110+ return -EINVAL;112111 }113112 if (info->mode != IPT_TTL_SET && info->ttl == 0)114114- return false;115115- return true;113113+ return -EINVAL;114114+ return 0;116115}117116118118-static bool hl_tg6_check(const struct xt_tgchk_param *par)117117+static int hl_tg6_check(const struct xt_tgchk_param *par)119118{120119 const struct ip6t_HL_info *info = par->targinfo;121120122121 if (info->mode > IP6T_HL_MAXMODE) {123123- printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n",124124- info->mode);125125- return false;122122+ pr_info("invalid or unknown mode %u\n", info->mode);123123+ return -EINVAL;126124 }127125 if (info->mode != IP6T_HL_SET && info->hop_limit == 0) {128128- printk(KERN_WARNING "ip6t_HL: increment/decrement doesn't "126126+ pr_info("increment/decrement does not "129127 "make sense with value 0\n");130130- return false;128128+ return -EINVAL;131129 }132132- return true;130130+ return 0;133131}134132135133static struct xt_target hl_tg_reg[] __read_mostly = {
+71-20
net/netfilter/xt_LED.c
···1818 * 02110-1301 USA.1919 *2020 */2121-2121+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt2222#include <linux/module.h>2323#include <linux/skbuff.h>2424#include <linux/netfilter/x_tables.h>···3232MODULE_AUTHOR("Adam Nielsen <a.nielsen@shikadi.net>");3333MODULE_DESCRIPTION("Xtables: trigger LED devices on packet match");34343535+static LIST_HEAD(xt_led_triggers);3636+static DEFINE_MUTEX(xt_led_mutex);3737+3538/*3639 * This is declared in here (the kernel module) only, to avoid having these3740 * dependencies in userspace code. This is what xt_led_info.internal_data3841 * points to.3942 */4043struct xt_led_info_internal {4444+ struct list_head list;4545+ int refcnt;4646+ char *trigger_id;4147 struct led_trigger netfilter_led_trigger;4248 struct timer_list timer;4349};···6054 */6155 if ((ledinfo->delay > 0) && ledinfo->always_blink &&6256 timer_pending(&ledinternal->timer))6363- led_trigger_event(&ledinternal->netfilter_led_trigger,LED_OFF);5757+ led_trigger_event(&ledinternal->netfilter_led_trigger, LED_OFF);64586559 led_trigger_event(&ledinternal->netfilter_led_trigger, LED_FULL);6660···81758276static void led_timeout_callback(unsigned long data)8377{8484- struct xt_led_info *ledinfo = (struct xt_led_info *)data;8585- struct xt_led_info_internal *ledinternal = ledinfo->internal_data;7878+ struct xt_led_info_internal *ledinternal = (struct xt_led_info_internal *)data;86798780 led_trigger_event(&ledinternal->netfilter_led_trigger, LED_OFF);8881}89829090-static bool led_tg_check(const struct xt_tgchk_param *par)8383+static struct xt_led_info_internal *led_trigger_lookup(const char *name)8484+{8585+ struct xt_led_info_internal *ledinternal;8686+8787+ list_for_each_entry(ledinternal, &xt_led_triggers, list) {8888+ if (!strcmp(name, ledinternal->netfilter_led_trigger.name)) {8989+ return ledinternal;9090+ }9191+ }9292+ return NULL;9393+}9494+9595+static int led_tg_check(const struct xt_tgchk_param *par)9196{9297 struct xt_led_info *ledinfo = par->targinfo;9398 struct xt_led_info_internal *ledinternal;9499 int err;9510096101 if (ledinfo->id[0] == '\0') {9797- printk(KERN_ERR KBUILD_MODNAME ": No 'id' parameter given.\n");9898- return false;102102+ pr_info("No 'id' parameter given.\n");103103+ return -EINVAL;99104 }100105106106+ mutex_lock(&xt_led_mutex);107107+108108+ ledinternal = led_trigger_lookup(ledinfo->id);109109+ if (ledinternal) {110110+ ledinternal->refcnt++;111111+ goto out;112112+ }113113+114114+ err = -ENOMEM;101115 ledinternal = kzalloc(sizeof(struct xt_led_info_internal), GFP_KERNEL);102102- if (!ledinternal) {103103- printk(KERN_CRIT KBUILD_MODNAME ": out of memory\n");104104- return false;105105- }116116+ if (!ledinternal)117117+ goto exit_mutex_only;106118107107- ledinternal->netfilter_led_trigger.name = ledinfo->id;119119+ ledinternal->trigger_id = kstrdup(ledinfo->id, GFP_KERNEL);120120+ if (!ledinternal->trigger_id)121121+ goto exit_internal_alloc;122122+123123+ ledinternal->refcnt = 1;124124+ ledinternal->netfilter_led_trigger.name = ledinternal->trigger_id;108125109126 err = led_trigger_register(&ledinternal->netfilter_led_trigger);110127 if (err) {111111- printk(KERN_CRIT KBUILD_MODNAME112112- ": led_trigger_register() failed\n");128128+ pr_warning("led_trigger_register() failed\n");113129 if (err == -EEXIST)114114- printk(KERN_ERR KBUILD_MODNAME115115- ": Trigger name is already in use.\n");130130+ pr_warning("Trigger name is already in use.\n");116131 goto exit_alloc;117132 }118133119134 /* See if we need to set up a timer */120135 if (ledinfo->delay > 0)121136 setup_timer(&ledinternal->timer, led_timeout_callback,122122- (unsigned long)ledinfo);137137+ (unsigned long)ledinternal);138138+139139+ list_add_tail(&ledinternal->list, &xt_led_triggers);140140+141141+out:142142+ mutex_unlock(&xt_led_mutex);123143124144 ledinfo->internal_data = ledinternal;125145126126- return true;146146+ return 0;127147128148exit_alloc:149149+ kfree(ledinternal->trigger_id);150150+151151+exit_internal_alloc:129152 kfree(ledinternal);130153131131- return false;154154+exit_mutex_only:155155+ mutex_unlock(&xt_led_mutex);156156+157157+ return err;132158}133159134160static void led_tg_destroy(const struct xt_tgdtor_param *par)···168130 const struct xt_led_info *ledinfo = par->targinfo;169131 struct xt_led_info_internal *ledinternal = ledinfo->internal_data;170132133133+ mutex_lock(&xt_led_mutex);134134+135135+ if (--ledinternal->refcnt) {136136+ mutex_unlock(&xt_led_mutex);137137+ return;138138+ }139139+140140+ list_del(&ledinternal->list);141141+171142 if (ledinfo->delay > 0)172143 del_timer_sync(&ledinternal->timer);173144174145 led_trigger_unregister(&ledinternal->netfilter_led_trigger);146146+147147+ mutex_unlock(&xt_led_mutex);148148+149149+ kfree(ledinternal->trigger_id);175150 kfree(ledinternal);176151}177152···193142 .revision = 0,194143 .family = NFPROTO_UNSPEC,195144 .target = led_tg,196196- .targetsize = XT_ALIGN(sizeof(struct xt_led_info)),145145+ .targetsize = sizeof(struct xt_led_info),197146 .checkentry = led_tg_check,198147 .destroy = led_tg_destroy,199148 .me = THIS_MODULE,
···99 * published by the Free Software Foundation.1010 *1111 */1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/module.h>1414#include <linux/skbuff.h>1515#include <linux/ip.h>···5959 return NF_DROP;6060}61616262-static bool tproxy_tg_check(const struct xt_tgchk_param *par)6262+static int tproxy_tg_check(const struct xt_tgchk_param *par)6363{6464 const struct ipt_ip *i = par->entryinfo;65656666 if ((i->proto == IPPROTO_TCP || i->proto == IPPROTO_UDP)6767 && !(i->invflags & IPT_INV_PROTO))6868- return true;6868+ return 0;69697070- pr_info("xt_TPROXY: Can be used only in combination with "7070+ pr_info("Can be used only in combination with "7171 "either -p tcp or -p udp\n");7272- return false;7272+ return -EINVAL;7373}74747575static struct xt_target tproxy_tg_reg __read_mostly = {
+10-9
net/netfilter/xt_cluster.c
···55 * it under the terms of the GNU General Public License version 2 as66 * published by the Free Software Foundation.77 */88+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt89#include <linux/module.h>910#include <linux/skbuff.h>1011#include <linux/jhash.h>···132131 !!(info->flags & XT_CLUSTER_F_INV);133132}134133135135-static bool xt_cluster_mt_checkentry(const struct xt_mtchk_param *par)134134+static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par)136135{137136 struct xt_cluster_match_info *info = par->matchinfo;138137139138 if (info->total_nodes > XT_CLUSTER_NODES_MAX) {140140- printk(KERN_ERR "xt_cluster: you have exceeded the maximum "141141- "number of cluster nodes (%u > %u)\n",142142- info->total_nodes, XT_CLUSTER_NODES_MAX);143143- return false;139139+ pr_info("you have exceeded the maximum "140140+ "number of cluster nodes (%u > %u)\n",141141+ info->total_nodes, XT_CLUSTER_NODES_MAX);142142+ return -EINVAL;144143 }145144 if (info->node_mask >= (1ULL << info->total_nodes)) {146146- printk(KERN_ERR "xt_cluster: this node mask cannot be "147147- "higher than the total number of nodes\n");148148- return false;145145+ pr_info("this node mask cannot be "146146+ "higher than the total number of nodes\n");147147+ return -EDOM;149148 }150150- return true;149149+ return 0;151150}152151153152static struct xt_match xt_cluster_match __read_mostly = {
+10-10
net/netfilter/xt_connbytes.c
···11/* Kernel module to match connection tracking byte counter.22 * GPL (C) 2002 Martin Devera (devik@cdi.cz).33 */44+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt45#include <linux/module.h>56#include <linux/bitops.h>67#include <linux/skbuff.h>···9392 return what >= sinfo->count.from;9493}95949696-static bool connbytes_mt_check(const struct xt_mtchk_param *par)9595+static int connbytes_mt_check(const struct xt_mtchk_param *par)9796{9897 const struct xt_connbytes_info *sinfo = par->matchinfo;9898+ int ret;9999100100 if (sinfo->what != XT_CONNBYTES_PKTS &&101101 sinfo->what != XT_CONNBYTES_BYTES &&102102 sinfo->what != XT_CONNBYTES_AVGPKT)103103- return false;103103+ return -EINVAL;104104105105 if (sinfo->direction != XT_CONNBYTES_DIR_ORIGINAL &&106106 sinfo->direction != XT_CONNBYTES_DIR_REPLY &&107107 sinfo->direction != XT_CONNBYTES_DIR_BOTH)108108- return false;108108+ return -EINVAL;109109110110- if (nf_ct_l3proto_try_module_get(par->family) < 0) {111111- printk(KERN_WARNING "can't load conntrack support for "112112- "proto=%u\n", par->family);113113- return false;114114- }115115-116116- return true;110110+ ret = nf_ct_l3proto_try_module_get(par->family);111111+ if (ret < 0)112112+ pr_info("cannot load conntrack support for proto=%u\n",113113+ par->family);114114+ return ret;117115}118116119117static void connbytes_mt_destroy(const struct xt_mtdtor_param *par)
+10-8
net/netfilter/xt_connlimit.c
···55 * Nov 2002: Martin Bene <martin.bene@icomedias.com>:66 * only ignore TIME_WAIT or gone connections77 * (C) CC Computer Consultants GmbH, 200788- * Contact: <jengelh@computergmbh.de>98 *109 * based on ...1110 *1211 * Kernel module to match connection tracking information.1312 * GPL (C) 1999 Rusty Russell (rusty@rustcorp.com.au).1413 */1414+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1515#include <linux/in.h>1616#include <linux/in6.h>1717#include <linux/ip.h>···217217 return false;218218}219219220220-static bool connlimit_mt_check(const struct xt_mtchk_param *par)220220+static int connlimit_mt_check(const struct xt_mtchk_param *par)221221{222222 struct xt_connlimit_info *info = par->matchinfo;223223 unsigned int i;224224+ int ret;224225225226 if (unlikely(!connlimit_rnd_inited)) {226227 get_random_bytes(&connlimit_rnd, sizeof(connlimit_rnd));227228 connlimit_rnd_inited = true;228229 }229229- if (nf_ct_l3proto_try_module_get(par->family) < 0) {230230- printk(KERN_WARNING "cannot load conntrack support for "231231- "address family %u\n", par->family);232232- return false;230230+ ret = nf_ct_l3proto_try_module_get(par->family);231231+ if (ret < 0) {232232+ pr_info("cannot load conntrack support for "233233+ "address family %u\n", par->family);234234+ return ret;233235 }234236235237 /* init private data */236238 info->data = kmalloc(sizeof(struct xt_connlimit_data), GFP_KERNEL);237239 if (info->data == NULL) {238240 nf_ct_l3proto_module_put(par->family);239239- return false;241241+ return -ENOMEM;240242 }241243242244 spin_lock_init(&info->data->lock);243245 for (i = 0; i < ARRAY_SIZE(info->data->iphash); ++i)244246 INIT_LIST_HEAD(&info->data->iphash[i]);245247246246- return true;248248+ return 0;247249}248250249251static void connlimit_mt_destroy(const struct xt_mtdtor_param *par)
···99 * it under the terms of the GNU General Public License version 2 as1010 * published by the Free Software Foundation.1111 */1212-1212+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1313#include <linux/module.h>1414#include <linux/skbuff.h>1515#include <net/ipv6.h>···206206 return conntrack_mt(skb, par, info->state_mask, info->status_mask);207207}208208209209-static bool conntrack_mt_check(const struct xt_mtchk_param *par)209209+static int conntrack_mt_check(const struct xt_mtchk_param *par)210210{211211- if (nf_ct_l3proto_try_module_get(par->family) < 0) {212212- printk(KERN_WARNING "can't load conntrack support for "213213- "proto=%u\n", par->family);214214- return false;215215- }216216- return true;211211+ int ret;212212+213213+ ret = nf_ct_l3proto_try_module_get(par->family);214214+ if (ret < 0)215215+ pr_info("cannot load conntrack support for proto=%u\n",216216+ par->family);217217+ return ret;217218}218219219220static void conntrack_mt_destroy(const struct xt_mtdtor_param *par)
···66 * it under the terms of the GNU General Public License version 2 as77 * published by the Free Software Foundation.88 */99-99+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1010#include <linux/module.h>1111#include <linux/skbuff.h>1212#include <linux/ip.h>···4242 return (dscp == info->dscp) ^ !!info->invert;4343}44444545-static bool dscp_mt_check(const struct xt_mtchk_param *par)4545+static int dscp_mt_check(const struct xt_mtchk_param *par)4646{4747 const struct xt_dscp_info *info = par->matchinfo;48484949 if (info->dscp > XT_DSCP_MAX) {5050- printk(KERN_ERR "xt_dscp: dscp %x out of range\n", info->dscp);5151- return false;5050+ pr_info("dscp %x out of range\n", info->dscp);5151+ return -EDOM;5252 }53535454- return true;5454+ return 0;5555}56565757static bool tos_mt(const struct sk_buff *skb, const struct xt_match_param *par)5858{5959 const struct xt_tos_match_info *info = par->matchinfo;60606161- if (par->match->family == NFPROTO_IPV4)6161+ if (par->family == NFPROTO_IPV4)6262 return ((ip_hdr(skb)->tos & info->tos_mask) ==6363 info->tos_value) ^ !!info->invert;6464 else
+9-15
net/netfilter/xt_esp.c
···66 * it under the terms of the GNU General Public License version 2 as77 * published by the Free Software Foundation.88 */99-99+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1010#include <linux/module.h>1111#include <linux/skbuff.h>1212#include <linux/in.h>···2424MODULE_ALIAS("ipt_esp");2525MODULE_ALIAS("ip6t_esp");26262727-#if 02828-#define duprintf(format, args...) printk(format , ## args)2929-#else3030-#define duprintf(format, args...)3131-#endif3232-3327/* Returns 1 if the spi is matched by the range, 0 otherwise */3428static inline bool3529spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, bool invert)3630{3731 bool r;3838- duprintf("esp spi_match:%c 0x%x <= 0x%x <= 0x%x", invert ? '!' : ' ',3939- min, spi, max);3232+ pr_debug("spi_match:%c 0x%x <= 0x%x <= 0x%x\n",3333+ invert ? '!' : ' ', min, spi, max);4034 r = (spi >= min && spi <= max) ^ invert;4141- duprintf(" result %s\n", r ? "PASS" : "FAILED");3535+ pr_debug(" result %s\n", r ? "PASS" : "FAILED");4236 return r;4337}4438···5157 /* We've been asked to examine this packet, and we5258 * can't. Hence, no choice but to drop.5359 */5454- duprintf("Dropping evil ESP tinygram.\n");6060+ pr_debug("Dropping evil ESP tinygram.\n");5561 *par->hotdrop = true;5662 return false;5763 }···6066 !!(espinfo->invflags & XT_ESP_INV_SPI));6167}62686363-static bool esp_mt_check(const struct xt_mtchk_param *par)6969+static int esp_mt_check(const struct xt_mtchk_param *par)6470{6571 const struct xt_esp *espinfo = par->matchinfo;66726773 if (espinfo->invflags & ~XT_ESP_INV_MASK) {6868- duprintf("xt_esp: unknown flags %X\n", espinfo->invflags);6969- return false;7474+ pr_debug("unknown flags %X\n", espinfo->invflags);7575+ return -EINVAL;7076 }71777272- return true;7878+ return 0;7379}74807581static struct xt_match esp_mt_reg[] __read_mostly = {
+73-269
net/netfilter/xt_hashlimit.c
···77 *88 * Development of this code was funded by Astaro AG, http://www.astaro.com/99 */1010+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1011#include <linux/module.h>1112#include <linux/spinlock.h>1213#include <linux/random.h>···37363837MODULE_LICENSE("GPL");3938MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");4040-MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");3939+MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");4140MODULE_DESCRIPTION("Xtables: per hash-bucket rate-limit match");4241MODULE_ALIAS("ipt_hashlimit");4342MODULE_ALIAS("ip6t_hashlimit");···8180 struct dsthash_dst dst;82818382 /* modified structure members in the end */8383+ spinlock_t lock;8484 unsigned long expires; /* precalculated expiry time */8585 struct {8686 unsigned long prev; /* last modification */8787 u_int32_t credit;8888 u_int32_t credit_cap, cost;8989 } rateinfo;9090+ struct rcu_head rcu;9091};91929293struct xt_hashlimit_htable {···145142 u_int32_t hash = hash_dst(ht, dst);146143147144 if (!hlist_empty(&ht->hash[hash])) {148148- hlist_for_each_entry(ent, pos, &ht->hash[hash], node)149149- if (dst_cmp(ent, dst))145145+ hlist_for_each_entry_rcu(ent, pos, &ht->hash[hash], node)146146+ if (dst_cmp(ent, dst)) {147147+ spin_lock(&ent->lock);150148 return ent;149149+ }151150 }152151 return NULL;153152}···161156{162157 struct dsthash_ent *ent;163158159159+ spin_lock(&ht->lock);164160 /* initialize hash with random val at the time we allocate165161 * the first hashtable entry */166166- if (!ht->rnd_initialized) {162162+ if (unlikely(!ht->rnd_initialized)) {167163 get_random_bytes(&ht->rnd, sizeof(ht->rnd));168164 ht->rnd_initialized = true;169165 }···172166 if (ht->cfg.max && ht->count >= ht->cfg.max) {173167 /* FIXME: do something. question is what.. */174168 if (net_ratelimit())175175- printk(KERN_WARNING176176- "xt_hashlimit: max count of %u reached\n",177177- ht->cfg.max);178178- return NULL;179179- }180180-181181- ent = kmem_cache_alloc(hashlimit_cachep, GFP_ATOMIC);169169+ pr_err("max count of %u reached\n", ht->cfg.max);170170+ ent = NULL;171171+ } else172172+ ent = kmem_cache_alloc(hashlimit_cachep, GFP_ATOMIC);182173 if (!ent) {183174 if (net_ratelimit())184184- printk(KERN_ERR185185- "xt_hashlimit: can't allocate dsthash_ent\n");186186- return NULL;187187- }188188- memcpy(&ent->dst, dst, sizeof(ent->dst));175175+ pr_err("cannot allocate dsthash_ent\n");176176+ } else {177177+ memcpy(&ent->dst, dst, sizeof(ent->dst));178178+ spin_lock_init(&ent->lock);189179190190- hlist_add_head(&ent->node, &ht->hash[hash_dst(ht, dst)]);191191- ht->count++;180180+ spin_lock(&ent->lock);181181+ hlist_add_head_rcu(&ent->node, &ht->hash[hash_dst(ht, dst)]);182182+ ht->count++;183183+ }184184+ spin_unlock(&ht->lock);192185 return ent;186186+}187187+188188+static void dsthash_free_rcu(struct rcu_head *head)189189+{190190+ struct dsthash_ent *ent = container_of(head, struct dsthash_ent, rcu);191191+192192+ kmem_cache_free(hashlimit_cachep, ent);193193}194194195195static inline void196196dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent)197197{198198- hlist_del(&ent->node);199199- kmem_cache_free(hashlimit_cachep, ent);198198+ hlist_del_rcu(&ent->node);199199+ call_rcu_bh(&ent->rcu, dsthash_free_rcu);200200 ht->count--;201201}202202static void htable_gc(unsigned long htlong);203203-204204-static int htable_create_v0(struct net *net, struct xt_hashlimit_info *minfo, u_int8_t family)205205-{206206- struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);207207- struct xt_hashlimit_htable *hinfo;208208- unsigned int size;209209- unsigned int i;210210-211211- if (minfo->cfg.size)212212- size = minfo->cfg.size;213213- else {214214- size = ((totalram_pages << PAGE_SHIFT) / 16384) /215215- sizeof(struct list_head);216216- if (totalram_pages > (1024 * 1024 * 1024 / PAGE_SIZE))217217- size = 8192;218218- if (size < 16)219219- size = 16;220220- }221221- /* FIXME: don't use vmalloc() here or anywhere else -HW */222222- hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +223223- sizeof(struct list_head) * size);224224- if (!hinfo) {225225- printk(KERN_ERR "xt_hashlimit: unable to create hashtable\n");226226- return -1;227227- }228228- minfo->hinfo = hinfo;229229-230230- /* copy match config into hashtable config */231231- hinfo->cfg.mode = minfo->cfg.mode;232232- hinfo->cfg.avg = minfo->cfg.avg;233233- hinfo->cfg.burst = minfo->cfg.burst;234234- hinfo->cfg.max = minfo->cfg.max;235235- hinfo->cfg.gc_interval = minfo->cfg.gc_interval;236236- hinfo->cfg.expire = minfo->cfg.expire;237237-238238- if (family == NFPROTO_IPV4)239239- hinfo->cfg.srcmask = hinfo->cfg.dstmask = 32;240240- else241241- hinfo->cfg.srcmask = hinfo->cfg.dstmask = 128;242242-243243- hinfo->cfg.size = size;244244- if (!hinfo->cfg.max)245245- hinfo->cfg.max = 8 * hinfo->cfg.size;246246- else if (hinfo->cfg.max < hinfo->cfg.size)247247- hinfo->cfg.max = hinfo->cfg.size;248248-249249- for (i = 0; i < hinfo->cfg.size; i++)250250- INIT_HLIST_HEAD(&hinfo->hash[i]);251251-252252- hinfo->use = 1;253253- hinfo->count = 0;254254- hinfo->family = family;255255- hinfo->rnd_initialized = false;256256- spin_lock_init(&hinfo->lock);257257- hinfo->pde = proc_create_data(minfo->name, 0,258258- (family == NFPROTO_IPV4) ?259259- hashlimit_net->ipt_hashlimit : hashlimit_net->ip6t_hashlimit,260260- &dl_file_ops, hinfo);261261- if (!hinfo->pde) {262262- vfree(hinfo);263263- return -1;264264- }265265- hinfo->net = net;266266-267267- setup_timer(&hinfo->timer, htable_gc, (unsigned long )hinfo);268268- hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);269269- add_timer(&hinfo->timer);270270-271271- hlist_add_head(&hinfo->node, &hashlimit_net->htables);272272-273273- return 0;274274-}275203276204static int htable_create(struct net *net, struct xt_hashlimit_mtinfo1 *minfo,277205 u_int8_t family)···228288 /* FIXME: don't use vmalloc() here or anywhere else -HW */229289 hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +230290 sizeof(struct list_head) * size);231231- if (hinfo == NULL) {232232- printk(KERN_ERR "xt_hashlimit: unable to create hashtable\n");233233- return -1;234234- }291291+ if (hinfo == NULL)292292+ return -ENOMEM;235293 minfo->hinfo = hinfo;236294237295 /* copy match config into hashtable config */···255317 &dl_file_ops, hinfo);256318 if (hinfo->pde == NULL) {257319 vfree(hinfo);258258- return -1;320320+ return -ENOMEM;259321 }260322 hinfo->net = net;261323···516578}517579518580static bool519519-hashlimit_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)520520-{521521- const struct xt_hashlimit_info *r = par->matchinfo;522522- struct xt_hashlimit_htable *hinfo = r->hinfo;523523- unsigned long now = jiffies;524524- struct dsthash_ent *dh;525525- struct dsthash_dst dst;526526-527527- if (hashlimit_init_dst(hinfo, &dst, skb, par->thoff) < 0)528528- goto hotdrop;529529-530530- spin_lock_bh(&hinfo->lock);531531- dh = dsthash_find(hinfo, &dst);532532- if (!dh) {533533- dh = dsthash_alloc_init(hinfo, &dst);534534- if (!dh) {535535- spin_unlock_bh(&hinfo->lock);536536- goto hotdrop;537537- }538538-539539- dh->expires = jiffies + msecs_to_jiffies(hinfo->cfg.expire);540540- dh->rateinfo.prev = jiffies;541541- dh->rateinfo.credit = user2credits(hinfo->cfg.avg *542542- hinfo->cfg.burst);543543- dh->rateinfo.credit_cap = user2credits(hinfo->cfg.avg *544544- hinfo->cfg.burst);545545- dh->rateinfo.cost = user2credits(hinfo->cfg.avg);546546- } else {547547- /* update expiration timeout */548548- dh->expires = now + msecs_to_jiffies(hinfo->cfg.expire);549549- rateinfo_recalc(dh, now);550550- }551551-552552- if (dh->rateinfo.credit >= dh->rateinfo.cost) {553553- /* We're underlimit. */554554- dh->rateinfo.credit -= dh->rateinfo.cost;555555- spin_unlock_bh(&hinfo->lock);556556- return true;557557- }558558-559559- spin_unlock_bh(&hinfo->lock);560560-561561- /* default case: we're overlimit, thus don't match */562562- return false;563563-564564-hotdrop:565565- *par->hotdrop = true;566566- return false;567567-}568568-569569-static bool570581hashlimit_mt(const struct sk_buff *skb, const struct xt_match_param *par)571582{572583 const struct xt_hashlimit_mtinfo1 *info = par->matchinfo;···527640 if (hashlimit_init_dst(hinfo, &dst, skb, par->thoff) < 0)528641 goto hotdrop;529642530530- spin_lock_bh(&hinfo->lock);643643+ rcu_read_lock_bh();531644 dh = dsthash_find(hinfo, &dst);532645 if (dh == NULL) {533646 dh = dsthash_alloc_init(hinfo, &dst);534647 if (dh == NULL) {535535- spin_unlock_bh(&hinfo->lock);648648+ rcu_read_unlock_bh();536649 goto hotdrop;537650 }538538-539651 dh->expires = jiffies + msecs_to_jiffies(hinfo->cfg.expire);540652 dh->rateinfo.prev = jiffies;541653 dh->rateinfo.credit = user2credits(hinfo->cfg.avg *···551665 if (dh->rateinfo.credit >= dh->rateinfo.cost) {552666 /* below the limit */553667 dh->rateinfo.credit -= dh->rateinfo.cost;554554- spin_unlock_bh(&hinfo->lock);668668+ spin_unlock(&dh->lock);669669+ rcu_read_unlock_bh();555670 return !(info->cfg.mode & XT_HASHLIMIT_INVERT);556671 }557672558558- spin_unlock_bh(&hinfo->lock);673673+ spin_unlock(&dh->lock);674674+ rcu_read_unlock_bh();559675 /* default match is underlimit - so over the limit, we need to invert */560676 return info->cfg.mode & XT_HASHLIMIT_INVERT;561677···566678 return false;567679}568680569569-static bool hashlimit_mt_check_v0(const struct xt_mtchk_param *par)570570-{571571- struct net *net = par->net;572572- struct xt_hashlimit_info *r = par->matchinfo;573573-574574- /* Check for overflow. */575575- if (r->cfg.burst == 0 ||576576- user2credits(r->cfg.avg * r->cfg.burst) < user2credits(r->cfg.avg)) {577577- printk(KERN_ERR "xt_hashlimit: overflow, try lower: %u/%u\n",578578- r->cfg.avg, r->cfg.burst);579579- return false;580580- }581581- if (r->cfg.mode == 0 ||582582- r->cfg.mode > (XT_HASHLIMIT_HASH_DPT |583583- XT_HASHLIMIT_HASH_DIP |584584- XT_HASHLIMIT_HASH_SIP |585585- XT_HASHLIMIT_HASH_SPT))586586- return false;587587- if (!r->cfg.gc_interval)588588- return false;589589- if (!r->cfg.expire)590590- return false;591591- if (r->name[sizeof(r->name) - 1] != '\0')592592- return false;593593-594594- mutex_lock(&hashlimit_mutex);595595- r->hinfo = htable_find_get(net, r->name, par->match->family);596596- if (!r->hinfo && htable_create_v0(net, r, par->match->family) != 0) {597597- mutex_unlock(&hashlimit_mutex);598598- return false;599599- }600600- mutex_unlock(&hashlimit_mutex);601601-602602- return true;603603-}604604-605605-static bool hashlimit_mt_check(const struct xt_mtchk_param *par)681681+static int hashlimit_mt_check(const struct xt_mtchk_param *par)606682{607683 struct net *net = par->net;608684 struct xt_hashlimit_mtinfo1 *info = par->matchinfo;685685+ int ret;609686610687 /* Check for overflow. */611688 if (info->cfg.burst == 0 ||612689 user2credits(info->cfg.avg * info->cfg.burst) <613690 user2credits(info->cfg.avg)) {614614- printk(KERN_ERR "xt_hashlimit: overflow, try lower: %u/%u\n",615615- info->cfg.avg, info->cfg.burst);616616- return false;691691+ pr_info("overflow, try lower: %u/%u\n",692692+ info->cfg.avg, info->cfg.burst);693693+ return -ERANGE;617694 }618695 if (info->cfg.gc_interval == 0 || info->cfg.expire == 0)619619- return false;696696+ return -EINVAL;620697 if (info->name[sizeof(info->name)-1] != '\0')621621- return false;622622- if (par->match->family == NFPROTO_IPV4) {698698+ return -EINVAL;699699+ if (par->family == NFPROTO_IPV4) {623700 if (info->cfg.srcmask > 32 || info->cfg.dstmask > 32)624624- return false;701701+ return -EINVAL;625702 } else {626703 if (info->cfg.srcmask > 128 || info->cfg.dstmask > 128)627627- return false;704704+ return -EINVAL;628705 }629706630707 mutex_lock(&hashlimit_mutex);631631- info->hinfo = htable_find_get(net, info->name, par->match->family);632632- if (!info->hinfo && htable_create(net, info, par->match->family) != 0) {633633- mutex_unlock(&hashlimit_mutex);634634- return false;708708+ info->hinfo = htable_find_get(net, info->name, par->family);709709+ if (info->hinfo == NULL) {710710+ ret = htable_create(net, info, par->family);711711+ if (ret < 0) {712712+ mutex_unlock(&hashlimit_mutex);713713+ return ret;714714+ }635715 }636716 mutex_unlock(&hashlimit_mutex);637637- return true;638638-}639639-640640-static void641641-hashlimit_mt_destroy_v0(const struct xt_mtdtor_param *par)642642-{643643- const struct xt_hashlimit_info *r = par->matchinfo;644644-645645- htable_put(r->hinfo);717717+ return 0;646718}647719648720static void hashlimit_mt_destroy(const struct xt_mtdtor_param *par)···612764 htable_put(info->hinfo);613765}614766615615-#ifdef CONFIG_COMPAT616616-struct compat_xt_hashlimit_info {617617- char name[IFNAMSIZ];618618- struct hashlimit_cfg cfg;619619- compat_uptr_t hinfo;620620- compat_uptr_t master;621621-};622622-623623-static void hashlimit_mt_compat_from_user(void *dst, const void *src)624624-{625625- int off = offsetof(struct compat_xt_hashlimit_info, hinfo);626626-627627- memcpy(dst, src, off);628628- memset(dst + off, 0, sizeof(struct compat_xt_hashlimit_info) - off);629629-}630630-631631-static int hashlimit_mt_compat_to_user(void __user *dst, const void *src)632632-{633633- int off = offsetof(struct compat_xt_hashlimit_info, hinfo);634634-635635- return copy_to_user(dst, src, off) ? -EFAULT : 0;636636-}637637-#endif638638-639767static struct xt_match hashlimit_mt_reg[] __read_mostly = {640640- {641641- .name = "hashlimit",642642- .revision = 0,643643- .family = NFPROTO_IPV4,644644- .match = hashlimit_mt_v0,645645- .matchsize = sizeof(struct xt_hashlimit_info),646646-#ifdef CONFIG_COMPAT647647- .compatsize = sizeof(struct compat_xt_hashlimit_info),648648- .compat_from_user = hashlimit_mt_compat_from_user,649649- .compat_to_user = hashlimit_mt_compat_to_user,650650-#endif651651- .checkentry = hashlimit_mt_check_v0,652652- .destroy = hashlimit_mt_destroy_v0,653653- .me = THIS_MODULE654654- },655768 {656769 .name = "hashlimit",657770 .revision = 1,···624815 .me = THIS_MODULE,625816 },626817#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)627627- {628628- .name = "hashlimit",629629- .family = NFPROTO_IPV6,630630- .match = hashlimit_mt_v0,631631- .matchsize = sizeof(struct xt_hashlimit_info),632632-#ifdef CONFIG_COMPAT633633- .compatsize = sizeof(struct compat_xt_hashlimit_info),634634- .compat_from_user = hashlimit_mt_compat_from_user,635635- .compat_to_user = hashlimit_mt_compat_to_user,636636-#endif637637- .checkentry = hashlimit_mt_check_v0,638638- .destroy = hashlimit_mt_destroy_v0,639639- .me = THIS_MODULE640640- },641818 {642819 .name = "hashlimit",643820 .revision = 1,···683888static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,684889 struct seq_file *s)685890{891891+ int res;892892+893893+ spin_lock(&ent->lock);686894 /* recalculate to show accurate numbers */687895 rateinfo_recalc(ent, jiffies);688896689897 switch (family) {690898 case NFPROTO_IPV4:691691- return seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",899899+ res = seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",692900 (long)(ent->expires - jiffies)/HZ,693901 &ent->dst.ip.src,694902 ntohs(ent->dst.src_port),···699901 ntohs(ent->dst.dst_port),700902 ent->rateinfo.credit, ent->rateinfo.credit_cap,701903 ent->rateinfo.cost);904904+ break;702905#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)703906 case NFPROTO_IPV6:704704- return seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",907907+ res = seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",705908 (long)(ent->expires - jiffies)/HZ,706909 &ent->dst.ip6.src,707910 ntohs(ent->dst.src_port),···710911 ntohs(ent->dst.dst_port),711912 ent->rateinfo.credit, ent->rateinfo.credit_cap,712913 ent->rateinfo.cost);914914+ break;713915#endif714916 default:715917 BUG();716716- return 0;918918+ res = 0;717919 }920920+ spin_unlock(&ent->lock);921921+ return res;718922}719923720924static int dl_seq_show(struct seq_file *s, void *v)···8261024 sizeof(struct dsthash_ent), 0, 0,8271025 NULL);8281026 if (!hashlimit_cachep) {829829- printk(KERN_ERR "xt_hashlimit: unable to create slab cache\n");10271027+ pr_warning("unable to create slab cache\n");8301028 goto err2;8311029 }8321030 return 0;···84110398421040static void __exit hashlimit_mt_exit(void)8431041{844844- kmem_cache_destroy(hashlimit_cachep);8451042 xt_unregister_matches(hashlimit_mt_reg, ARRAY_SIZE(hashlimit_mt_reg));8461043 unregister_pernet_subsys(&hashlimit_net_ops);10441044+10451045+ rcu_barrier_bh();10461046+ kmem_cache_destroy(hashlimit_cachep);8471047}84810488491049module_init(hashlimit_mt_init);
+9-7
net/netfilter/xt_helper.c
···66 * it under the terms of the GNU General Public License version 2 as77 * published by the Free Software Foundation.88 */99-99+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1010#include <linux/module.h>1111#include <linux/skbuff.h>1212#include <linux/netfilter.h>···5454 return ret;5555}56565757-static bool helper_mt_check(const struct xt_mtchk_param *par)5757+static int helper_mt_check(const struct xt_mtchk_param *par)5858{5959 struct xt_helper_info *info = par->matchinfo;6060+ int ret;60616161- if (nf_ct_l3proto_try_module_get(par->family) < 0) {6262- printk(KERN_WARNING "can't load conntrack support for "6363- "proto=%u\n", par->family);6464- return false;6262+ ret = nf_ct_l3proto_try_module_get(par->family);6363+ if (ret < 0) {6464+ pr_info("cannot load conntrack support for proto=%u\n",6565+ par->family);6666+ return ret;6567 }6668 info->name[29] = '\0';6767- return true;6969+ return 0;6870}69717072static void helper_mt_destroy(const struct xt_mtdtor_param *par)
···88 * it under the terms of the GNU General Public License version 2 as99 * published by the Free Software Foundation.1010 */1111+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1112#include <linux/module.h>1213#include <linux/skbuff.h>1314#include <linux/ip.h>
+7-6
net/netfilter/xt_limit.c
···55 * it under the terms of the GNU General Public License version 2 as66 * published by the Free Software Foundation.77 */88+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt89910#include <linux/slab.h>1011#include <linux/module.h>···9998 return (user * HZ * CREDITS_PER_JIFFY) / XT_LIMIT_SCALE;10099}101100102102-static bool limit_mt_check(const struct xt_mtchk_param *par)101101+static int limit_mt_check(const struct xt_mtchk_param *par)103102{104103 struct xt_rateinfo *r = par->matchinfo;105104 struct xt_limit_priv *priv;···107106 /* Check for overflow. */108107 if (r->burst == 0109108 || user2credits(r->avg * r->burst) < user2credits(r->avg)) {110110- printk("Overflow in xt_limit, try lower: %u/%u\n",111111- r->avg, r->burst);112112- return false;109109+ pr_info("Overflow, try lower: %u/%u\n",110110+ r->avg, r->burst);111111+ return -ERANGE;113112 }114113115114 priv = kmalloc(sizeof(*priv), GFP_KERNEL);116115 if (priv == NULL)117117- return false;116116+ return -ENOMEM;118117119118 /* For SMP, we only want to use one set of state. */120119 r->master = priv;···126125 r->credit_cap = user2credits(r->avg * r->burst); /* Credits full. */127126 r->cost = user2credits(r->avg);128127 }129129- return true;128128+ return 0;130129}131130132131static void limit_mt_destroy(const struct xt_mtdtor_param *par)