summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorfnm3 <fnm3>2002-11-19 12:00:13 +0000
committerfnm3 <fnm3>2002-11-19 12:00:13 +0000
commit14b715ae84a126074b1eb264408aaa8bac5baf53 (patch)
treecfc2ca1ce303ec9bbc38b3068d845fdfec5efe8f /kernel
parentd12ea3807e0dafc69f75ee1126e0255ccbd4435d (diff)
Removed (" __DATE__ " " __TIME__ ") from version
Increased version nomber frpm 0.5 to 0.6 Removed __FILE__ ":" __FUNCTION__ from DEBUG_MSG(...) macro Removed huge comments Added mask for prio: (TCI >> 13) & 0x7 Removed extended debug messages in the ebt_check_vlan function Removed all debug messages in the ebt_check_vlan function Changed vlan id range check from 4094 to VLAN_GROUP_ARRAY_LEN Removed info->bitmask &= ~EBT_VLAN_ID for vlan id = 0
Diffstat (limited to 'kernel')
-rw-r--r--kernel/linux/net/bridge/netfilter/ebt_vlan.c107
1 files changed, 25 insertions, 82 deletions
diff --git a/kernel/linux/net/bridge/netfilter/ebt_vlan.c b/kernel/linux/net/bridge/netfilter/ebt_vlan.c
index 261fde0..b3b9964 100644
--- a/kernel/linux/net/bridge/netfilter/ebt_vlan.c
+++ b/kernel/linux/net/bridge/netfilter/ebt_vlan.c
@@ -25,7 +25,7 @@
#include <linux/netfilter_bridge/ebt_vlan.h>
static unsigned char debug;
-#define MODULE_VERSION "0.5 (" __DATE__ " " __TIME__ ")"
+#define MODULE_VERSION "0.6"
MODULE_PARM(debug, "0-1b");
MODULE_PARM_DESC(debug, "debug=1 is turn on debug messages");
@@ -35,7 +35,7 @@ MODULE_DESCRIPTION("802.1Q match module (ebtables extension), v"
MODULE_LICENSE("GPL");
-#define DEBUG_MSG(...) if (debug) printk (KERN_DEBUG __FILE__ ":" __FUNCTION__ ": " __VA_ARGS__)
+#define DEBUG_MSG(...) if (debug) printk (KERN_DEBUG "ebt_vlan: " __VA_ARGS__)
#define INV_FLAG(_inv_flag_) (info->invflags & _inv_flag_) ? "!" : ""
#define GET_BITMASK(_BIT_MASK_) info->bitmask & _BIT_MASK_
#define SET_BITMASK(_BIT_MASK_) info->bitmask |= _BIT_MASK_
@@ -74,60 +74,35 @@ ebt_filter_vlan(const struct sk_buff *skb,
/*
* Tag Control Information (TCI) consists of the following elements:
- * - User_priority. This field allows the tagged frame to carry user_priority
- * information across Bridged LANs in which individual LAN segments may be unable to signal
- * priority information (e.g., 802.3/Ethernet segments).
- * The user_priority field is three bits in length,
- * interpreted as a binary number. The user_priority is therefore
- * capable of representing eight priority levels, 0 through 7.
- * The use and interpretation of this field is defined in ISO/IEC 15802-3.
- * - Canonical Format Indicator (CFI). This field is used,
- * in 802.3/Ethernet, to signal the presence or absence
- * of a RIF field, and, in combination with the Non-canonical Format Indicator (NCFI) carried
- * in the RIF, to signal the bit order of address information carried in the encapsulated
- * frame. The Canonical Format Indicator (CFI) is a single bit flag value.
- * - VLAN Identifier (VID). This field uniquely identifies the VLAN to
- * which the frame belongs. The twelve-bit VLAN Identifier (VID) field
- * uniquely identify the VLAN to which the frame belongs.
- * The VID is encoded as an unsigned binary number.
+ * - User_priority. The user_priority field is three bits in length,
+ * interpreted as a binary number.
+ * - Canonical Format Indicator (CFI). The Canonical Format Indicator
+ * (CFI) is a single bit flag value. Currently ignored.
+ * - VLAN Identifier (VID). The VID is encoded as
+ * an unsigned binary number.
*/
TCI = ntohs(frame->h_vlan_TCI);
- id = TCI & 0xFFF;
- prio = TCI >> 13;
+ id = TCI & VLAN_VID_MASK;
+ prio = (TCI >> 13) & 0x7;
encap = frame->h_vlan_encapsulated_proto;
- DEBUG_MSG
- ("ebt_vlan_info id=%d prio=%d encap=%2.4X bitmask=%2.2X\n",
- info->id, info->prio, ntohs(info->encap), info->bitmask);
- DEBUG_MSG("vlan_ethhdr id=%d prio=%d encap=%2.4X\n", id, prio,
- ntohs(encap));
-
/*
* Checking VLAN Identifier (VID)
*/
if (GET_BITMASK(EBT_VLAN_ID)) { /* Is VLAN ID parsed? */
EXIT_ON_MISMATCH(id, EBT_VLAN_ID);
- DEBUG_MSG
- ("matched rule id=%s%d for frame id=%d\n",
- INV_FLAG(EBT_VLAN_ID), info->id, id);
}
/*
* Checking user_priority
*/
if (GET_BITMASK(EBT_VLAN_PRIO)) { /* Is VLAN user_priority parsed? */
EXIT_ON_MISMATCH(prio, EBT_VLAN_PRIO);
- DEBUG_MSG
- ("matched rule prio=%s%d for frame prio=%d\n",
- INV_FLAG(EBT_VLAN_PRIO), info->prio, prio);
}
/*
* Checking Encapsulated Proto (Length/Type) field
*/
if (GET_BITMASK(EBT_VLAN_ENCAP)) { /* Is VLAN Encap parsed? */
EXIT_ON_MISMATCH(encap, EBT_VLAN_ENCAP);
- DEBUG_MSG("matched encap=%s%2.4X for frame encap=%2.4X\n",
- INV_FLAG(EBT_VLAN_ENCAP),
- ntohs(info->encap), ntohs(encap));
}
/*
* All possible extension parameters was parsed.
@@ -138,7 +113,7 @@ ebt_filter_vlan(const struct sk_buff *skb,
/*
* Function description: ebt_vlan_check() is called when userspace
- * delivers the table to the kernel,
+ * delivers the table entry to the kernel,
* and to check that userspace doesn't give a bad table.
* Parameters:
* const char *tablename - table name string
@@ -157,15 +132,12 @@ ebt_check_vlan(const char *tablename,
{
struct ebt_vlan_info *info = (struct ebt_vlan_info *) data;
- DEBUG_MSG
- ("received ebt_vlan_info id=%d prio=%d encap=%2.4X bitmask=%2.2X\n",
- info->id, info->prio, ntohs(info->encap), info->bitmask);
/*
* Parameters buffer overflow check
*/
if (datalen != sizeof(struct ebt_vlan_info)) {
DEBUG_MSG
- ("params size %d is not eq to ebt_vlan_info (%d)\n",
+ ("passed size %d is not eq to ebt_vlan_info (%d)\n",
datalen, sizeof(struct ebt_vlan_info));
return -EINVAL;
}
@@ -202,31 +174,16 @@ ebt_check_vlan(const char *tablename,
/*
* Reserved VLAN ID (VID) values
* -----------------------------
- * 0 - The null VLAN ID. Indicates that the tag header contains only user_priority information;
- * no VLAN identifier is present in the frame. This VID value shall not be
- * configured as a PVID, configured in any Filtering Database entry, or used in any
- * Management operation.
- *
- * 1 - The default Port VID (PVID) value used for classifying frames on ingress through a Bridge
- * Port. The PVID value can be changed by management on a per-Port basis.
- *
- * 0x0FFF - Reserved for implementation use. This VID value shall not be configured as a
- * PVID or transmitted in a tag header.
- *
- * The remaining values of VID are available for general use as VLAN identifiers.
- * A Bridge may implement the ability to support less than the full range of VID values;
- * i.e., for a given implementation,
- * an upper limit, N, is defined for the VID values supported, where N is less than or equal to 4094.
- * All implementations shall support the use of all VID values in the range 0 through their defined maximum
- * VID, N.
- *
- * For Linux, N = 4094.
+ * 0 - The null VLAN ID.
+ * 1 - The default Port VID (PVID)
+ * 0x0FFF - Reserved for implementation use.
+ * if_vlan.h: VLAN_GROUP_ARRAY_LEN 4096.
*/
if (GET_BITMASK(EBT_VLAN_ID)) { /* when vlan-id param was spec-ed */
if (!!info->id) { /* if id!=0 => check vid range */
- if (info->id > 4094) { /* check if id > than (0x0FFE) */
+ if (info->id > VLAN_GROUP_ARRAY_LEN) {
DEBUG_MSG
- ("vlan id %d is out of range (1-4094)\n",
+ ("id %d is out of range (1-4096)\n",
info->id);
return -EINVAL;
}
@@ -237,13 +194,10 @@ ebt_check_vlan(const char *tablename,
* So we just drop the prio flag.
*/
info->bitmask &= ~EBT_VLAN_PRIO;
- } else {
- /*
- * if id=0 (null VLAN ID) => Check for user_priority range
- * and clean EBT_VLAN_ID as useless
- */
- info->bitmask &= ~EBT_VLAN_ID;
}
+ /*
+ * Else, id=0 (null VLAN ID) => user_priority range (any?)
+ */
}
if (GET_BITMASK(EBT_VLAN_PRIO)) {
@@ -255,28 +209,19 @@ ebt_check_vlan(const char *tablename,
}
}
/*
- * Check for encapsulated proto range - it is possible to be any value for u_short range.
- * When relaying a tagged frame between 802.3/Ethernet MACs,
- * a Bridge may adjust the padding field such that
- * the minimum size of a transmitted tagged frame is 68 octets (7.2).
+ * Check for encapsulated proto range - it is possible to be
+ * any value for u_short range.
* if_ether.h: ETH_ZLEN 60 - Min. octets in frame sans FCS
*/
if (GET_BITMASK(EBT_VLAN_ENCAP)) {
if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) {
DEBUG_MSG
- ("encap farme length %d is less than minimal %d\n",
- ntohs(info->encap), ETH_ZLEN);
+ ("encap frame length %d is less than minimal\n",
+ ntohs(info->encap));
return -EINVAL;
}
}
- /*
- * Otherwise is all correct
- */
- DEBUG_MSG
- ("checked ebt_vlan_info id=%d prio=%d encap=%2.4X bitmask=%2.2X\n",
- info->id, info->prio, ntohs(info->encap), info->bitmask);
-
return 0;
}
@@ -291,7 +236,6 @@ static struct ebt_match filter_vlan = {
/*
* Module initialization function.
- * Called when module is loaded to kernelspace
*/
static int __init init(void)
{
@@ -303,7 +247,6 @@ static int __init init(void)
/*
* Module "finalization" function
- * Called when download module from kernelspace
*/
static void __exit fini(void)
{