Skip to content

Commit a4bf3af

Browse files
kaberDavid S. Miller
authored andcommitted
[VLAN]: Introduce symbolic constants for flag values
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b020cb4 commit a4bf3af

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

include/linux/if_vlan.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ enum vlan_ioctl_cmds {
398398
GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */
399399
};
400400

401+
enum vlan_flags {
402+
VLAN_FLAG_REORDER_HDR = 0x1,
403+
};
404+
401405
enum vlan_name_types {
402406
VLAN_NAME_TYPE_PLUS_VID, /* Name will look like: vlan0005 */
403407
VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like: eth1.0005 */

net/8021q/vlan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static int register_vlan_device(struct net_device *real_dev,
565565
VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
566566
VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
567567
VLAN_DEV_INFO(new_dev)->dent = NULL;
568-
VLAN_DEV_INFO(new_dev)->flags = 1;
568+
VLAN_DEV_INFO(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
569569

570570
err = register_vlan_dev(new_dev);
571571
if (err < 0)

net/8021q/vlan_dev.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ int vlan_dev_rebuild_header(struct sk_buff *skb)
7373

7474
static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
7575
{
76-
if (VLAN_DEV_INFO(skb->dev)->flags & 1) {
76+
if (VLAN_DEV_INFO(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) {
7777
if (skb_shared(skb) || skb_cloned(skb)) {
7878
struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
7979
kfree_skb(skb);
@@ -350,7 +350,8 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
350350
* header shuffling in the hard_start_xmit. Users can turn off this
351351
* REORDER behaviour with the vconfig tool.
352352
*/
353-
build_vlan_header = ((VLAN_DEV_INFO(dev)->flags & 1) == 0);
353+
if (!(VLAN_DEV_INFO(dev)->flags & VLAN_FLAG_REORDER_HDR))
354+
build_vlan_header = 1;
354355

355356
if (build_vlan_header) {
356357
vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
@@ -584,16 +585,16 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
584585
return 0;
585586
}
586587

587-
/* Flags are defined in the vlan_dev_info class in include/linux/if_vlan.h file. */
588+
/* Flags are defined in the vlan_flags enum in include/linux/if_vlan.h file. */
588589
int vlan_dev_set_vlan_flag(const struct net_device *dev,
589590
u32 flag, short flag_val)
590591
{
591592
/* verify flag is supported */
592-
if (flag == 1) {
593+
if (flag == VLAN_FLAG_REORDER_HDR) {
593594
if (flag_val) {
594-
VLAN_DEV_INFO(dev)->flags |= 1;
595+
VLAN_DEV_INFO(dev)->flags |= VLAN_FLAG_REORDER_HDR;
595596
} else {
596-
VLAN_DEV_INFO(dev)->flags &= ~1;
597+
VLAN_DEV_INFO(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
597598
}
598599
return 0;
599600
}

0 commit comments

Comments
 (0)