Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff67e4e4 authored by Jan Engelhardt's avatar Jan Engelhardt
Browse files

netfilter: xt extensions: use pr_<level> (2)



Supplement to 1159683e.

Downgrade the log level to INFO for most checkentry messages as they
are, IMO, just an extra information to the -EINVAL code that is
returned as part of a parameter "constraint violation". Leave errors
to real errors, such as being unable to create a LED trigger.

Signed-off-by: default avatarJan Engelhardt <jengelh@medozas.de>
parent 0d345455
Loading
Loading
Loading
Loading
+6 −9
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
 *  August, 2003
 *  August, 2003
 *
 *
 */
 */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/ip.h>
#include <linux/ip.h>
#include <linux/if_arp.h>
#include <linux/if_arp.h>
#include <linux/module.h>
#include <linux/module.h>
@@ -186,21 +187,17 @@ static bool ebt_among_mt_check(const struct xt_mtchk_param *par)
	expected_length += ebt_mac_wormhash_size(wh_src);
	expected_length += ebt_mac_wormhash_size(wh_src);


	if (em->match_size != EBT_ALIGN(expected_length)) {
	if (em->match_size != EBT_ALIGN(expected_length)) {
		printk(KERN_WARNING
		pr_info("wrong size: %d against expected %d, rounded to %Zd\n",
		       "ebtables: among: wrong size: %d "
		       "against expected %d, rounded to %Zd\n",
			em->match_size, expected_length,
			em->match_size, expected_length,
			EBT_ALIGN(expected_length));
			EBT_ALIGN(expected_length));
		return false;
		return false;
	}
	}
	if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
	if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
		printk(KERN_WARNING
		pr_info("dst integrity fail: %x\n", -err);
		       "ebtables: among: dst integrity fail: %x\n", -err);
		return false;
		return false;
	}
	}
	if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
	if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
		printk(KERN_WARNING
		pr_info("src integrity fail: %x\n", -err);
		       "ebtables: among: src integrity fail: %x\n", -err);
		return false;
		return false;
	}
	}
	return true;
	return true;
+2 −1
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@
 *  September, 2003
 *  September, 2003
 *
 *
 */
 */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
@@ -71,7 +72,7 @@ static bool ebt_limit_mt_check(const struct xt_mtchk_param *par)
	/* Check for overflow. */
	/* Check for overflow. */
	if (info->burst == 0 ||
	if (info->burst == 0 ||
	    user2credits(info->avg * info->burst) < user2credits(info->avg)) {
	    user2credits(info->avg * info->burst) < user2credits(info->avg)) {
		printk("Overflow in ebt_limit, try lower: %u/%u\n",
		pr_info("overflow, try lower: %u/%u\n",
			info->avg, info->burst);
			info->avg, info->burst);
		return false;
		return false;
	}
	}
+9 −14
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@
 *   flushed even if it is not full yet.
 *   flushed even if it is not full yet.
 *
 *
 */
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include <linux/socket.h>
#include <linux/socket.h>
@@ -43,9 +43,6 @@
#include <net/sock.h>
#include <net/sock.h>
#include "../br_private.h"
#include "../br_private.h"


#define PRINTR(format, args...) do { if (net_ratelimit()) \
				printk(format , ## args); } while (0)

static unsigned int nlbufsiz = NLMSG_GOODSIZE;
static unsigned int nlbufsiz = NLMSG_GOODSIZE;
module_param(nlbufsiz, uint, 0600);
module_param(nlbufsiz, uint, 0600);
MODULE_PARM_DESC(nlbufsiz, "netlink buffer size (number of bytes) "
MODULE_PARM_DESC(nlbufsiz, "netlink buffer size (number of bytes) "
@@ -106,14 +103,13 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size)
	n = max(size, nlbufsiz);
	n = max(size, nlbufsiz);
	skb = alloc_skb(n, GFP_ATOMIC);
	skb = alloc_skb(n, GFP_ATOMIC);
	if (!skb) {
	if (!skb) {
		PRINTR(KERN_ERR "ebt_ulog: can't alloc whole buffer "
		pr_debug("cannot alloc whole buffer of size %ub!\n", n);
		       "of size %ub!\n", n);
		if (n > size) {
		if (n > size) {
			/* try to allocate only as much as we need for
			/* try to allocate only as much as we need for
			 * current packet */
			 * current packet */
			skb = alloc_skb(size, GFP_ATOMIC);
			skb = alloc_skb(size, GFP_ATOMIC);
			if (!skb)
			if (!skb)
				PRINTR(KERN_ERR "ebt_ulog: can't even allocate "
				pr_debug("cannot even allocate "
					 "buffer of size %ub\n", size);
					 "buffer of size %ub\n", size);
		}
		}
	}
	}
@@ -141,8 +137,7 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,


	size = NLMSG_SPACE(sizeof(*pm) + copy_len);
	size = NLMSG_SPACE(sizeof(*pm) + copy_len);
	if (size > nlbufsiz) {
	if (size > nlbufsiz) {
		PRINTR("ebt_ulog: Size %Zd needed, but nlbufsiz=%d\n",
		pr_debug("Size %Zd needed, but nlbufsiz=%d\n", size, nlbufsiz);
		       size, nlbufsiz);
		return;
		return;
	}
	}


@@ -216,7 +211,7 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,
	return;
	return;


nlmsg_failure:
nlmsg_failure:
	printk(KERN_CRIT "ebt_ulog: error during NLMSG_PUT. This should "
	pr_debug("error during NLMSG_PUT. This should "
		 "not happen, please report to author.\n");
		 "not happen, please report to author.\n");
	goto unlock;
	goto unlock;
alloc_failure:
alloc_failure:
@@ -291,7 +286,7 @@ static int __init ebt_ulog_init(void)
	int i;
	int i;


	if (nlbufsiz >= 128*1024) {
	if (nlbufsiz >= 128*1024) {
		printk(KERN_NOTICE "ebt_ulog: Netlink buffer has to be <= 128kB,"
		pr_warning("Netlink buffer has to be <= 128kB,"
			   " please try a smaller nlbufsiz parameter.\n");
			   " please try a smaller nlbufsiz parameter.\n");
		return -EINVAL;
		return -EINVAL;
	}
	}
+13 −23
Original line number Original line Diff line number Diff line
@@ -26,17 +26,12 @@
#include <linux/netfilter_bridge/ebtables.h>
#include <linux/netfilter_bridge/ebtables.h>
#include <linux/netfilter_bridge/ebt_vlan.h>
#include <linux/netfilter_bridge/ebt_vlan.h>


static int debug;
#define MODULE_VERS "0.6"
#define MODULE_VERS "0.6"


module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "debug=1 is turn on debug messages");
MODULE_AUTHOR("Nick Fedchik <nick@fedchik.org.ua>");
MODULE_AUTHOR("Nick Fedchik <nick@fedchik.org.ua>");
MODULE_DESCRIPTION("Ebtables: 802.1Q VLAN tag match");
MODULE_DESCRIPTION("Ebtables: 802.1Q VLAN tag match");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");



#define DEBUG_MSG(args...) if (debug) printk (KERN_DEBUG "ebt_vlan: " args)
#define GET_BITMASK(_BIT_MASK_) info->bitmask & _BIT_MASK_
#define GET_BITMASK(_BIT_MASK_) info->bitmask & _BIT_MASK_
#define EXIT_ON_MISMATCH(_MATCH_,_MASK_) {if (!((info->_MATCH_ == _MATCH_)^!!(info->invflags & _MASK_))) return false; }
#define EXIT_ON_MISMATCH(_MATCH_,_MASK_) {if (!((info->_MATCH_ == _MATCH_)^!!(info->invflags & _MASK_))) return false; }


@@ -91,23 +86,22 @@ static bool ebt_vlan_mt_check(const struct xt_mtchk_param *par)


	/* Is it 802.1Q frame checked? */
	/* Is it 802.1Q frame checked? */
	if (e->ethproto != htons(ETH_P_8021Q)) {
	if (e->ethproto != htons(ETH_P_8021Q)) {
		DEBUG_MSG
		pr_debug("passed entry proto %2.4X is not 802.1Q (8100)\n",
		    ("passed entry proto %2.4X is not 802.1Q (8100)\n",
			 ntohs(e->ethproto));
		     (unsigned short) ntohs(e->ethproto));
		return false;
		return false;
	}
	}


	/* Check for bitmask range
	/* Check for bitmask range
	 * True if even one bit is out of mask */
	 * True if even one bit is out of mask */
	if (info->bitmask & ~EBT_VLAN_MASK) {
	if (info->bitmask & ~EBT_VLAN_MASK) {
		DEBUG_MSG("bitmask %2X is out of mask (%2X)\n",
		pr_debug("bitmask %2X is out of mask (%2X)\n",
			 info->bitmask, EBT_VLAN_MASK);
			 info->bitmask, EBT_VLAN_MASK);
		return false;
		return false;
	}
	}


	/* Check for inversion flags range */
	/* Check for inversion flags range */
	if (info->invflags & ~EBT_VLAN_MASK) {
	if (info->invflags & ~EBT_VLAN_MASK) {
		DEBUG_MSG("inversion flags %2X is out of mask (%2X)\n",
		pr_debug("inversion flags %2X is out of mask (%2X)\n",
			 info->invflags, EBT_VLAN_MASK);
			 info->invflags, EBT_VLAN_MASK);
		return false;
		return false;
	}
	}
@@ -121,8 +115,7 @@ static bool ebt_vlan_mt_check(const struct xt_mtchk_param *par)
	if (GET_BITMASK(EBT_VLAN_ID)) {
	if (GET_BITMASK(EBT_VLAN_ID)) {
		if (!!info->id) { /* if id!=0 => check vid range */
		if (!!info->id) { /* if id!=0 => check vid range */
			if (info->id > VLAN_GROUP_ARRAY_LEN) {
			if (info->id > VLAN_GROUP_ARRAY_LEN) {
				DEBUG_MSG
				pr_debug("id %d is out of range (1-4096)\n",
				    ("id %d is out of range (1-4096)\n",
					 info->id);
					 info->id);
				return false;
				return false;
			}
			}
@@ -137,7 +130,7 @@ static bool ebt_vlan_mt_check(const struct xt_mtchk_param *par)


	if (GET_BITMASK(EBT_VLAN_PRIO)) {
	if (GET_BITMASK(EBT_VLAN_PRIO)) {
		if ((unsigned char) info->prio > 7) {
		if ((unsigned char) info->prio > 7) {
			DEBUG_MSG("prio %d is out of range (0-7)\n",
			pr_debug("prio %d is out of range (0-7)\n",
				 info->prio);
				 info->prio);
			return false;
			return false;
		}
		}
@@ -147,9 +140,8 @@ static bool ebt_vlan_mt_check(const struct xt_mtchk_param *par)
	 * if_ether.h:  ETH_ZLEN        60   -  Min. octets in frame sans FCS */
	 * if_ether.h:  ETH_ZLEN        60   -  Min. octets in frame sans FCS */
	if (GET_BITMASK(EBT_VLAN_ENCAP)) {
	if (GET_BITMASK(EBT_VLAN_ENCAP)) {
		if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) {
		if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) {
			DEBUG_MSG
			pr_debug("encap frame length %d is less than "
			    ("encap frame length %d is less than minimal\n",
				 "minimal\n", ntohs(info->encap));
			     ntohs(info->encap));
			return false;
			return false;
		}
		}
	}
	}
@@ -169,9 +161,7 @@ static struct xt_match ebt_vlan_mt_reg __read_mostly = {


static int __init ebt_vlan_init(void)
static int __init ebt_vlan_init(void)
{
{
	DEBUG_MSG("ebtables 802.1Q extension module v"
	pr_debug("ebtables 802.1Q extension module v" MODULE_VERS "\n");
		  MODULE_VERS "\n");
	DEBUG_MSG("module debug=%d\n", !!debug);
	return xt_register_match(&ebt_vlan_mt_reg);
	return xt_register_match(&ebt_vlan_mt_reg);
}
}


+2 −3
Original line number Original line Diff line number Diff line
@@ -14,8 +14,7 @@
 *  as published by the Free Software Foundation; either version
 *  as published by the Free Software Foundation; either version
 *  2 of the License, or (at your option) any later version.
 *  2 of the License, or (at your option) any later version.
 */
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kmod.h>
#include <linux/kmod.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/vmalloc.h>
#include <linux/vmalloc.h>
@@ -2127,7 +2126,7 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
			return ret;
			return ret;
		new_offset += ret;
		new_offset += ret;
		if (offsets_update && new_offset) {
		if (offsets_update && new_offset) {
			pr_debug("ebtables: change offset %d to %d\n",
			pr_debug("change offset %d to %d\n",
				offsets_update[i], offsets[j] + new_offset);
				offsets_update[i], offsets[j] + new_offset);
			offsets_update[i] = offsets[j] + new_offset;
			offsets_update[i] = offsets[j] + new_offset;
		}
		}
Loading