Commit 7a17a2f7 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[VLAN]: Make the vlan_name_type per-net.

This includes moving one on the struct vlan_net and
s/vlan_name_type/vn->name_type/ over the code.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Acked-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 80de2d98
...@@ -52,9 +52,6 @@ static char vlan_version[] = DRV_VERSION; ...@@ -52,9 +52,6 @@ static char vlan_version[] = DRV_VERSION;
static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
/* Determines interface naming scheme. */
unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
static struct packet_type vlan_packet_type = { static struct packet_type vlan_packet_type = {
.type = __constant_htons(ETH_P_8021Q), .type = __constant_htons(ETH_P_8021Q),
.func = vlan_skb_recv, /* VLAN receive method */ .func = vlan_skb_recv, /* VLAN receive method */
...@@ -299,6 +296,8 @@ static int register_vlan_device(struct net_device *real_dev, ...@@ -299,6 +296,8 @@ static int register_vlan_device(struct net_device *real_dev,
unsigned short VLAN_ID) unsigned short VLAN_ID)
{ {
struct net_device *new_dev; struct net_device *new_dev;
struct net *net = dev_net(real_dev);
struct vlan_net *vn = net_generic(net, vlan_net_id);
char name[IFNAMSIZ]; char name[IFNAMSIZ];
int err; int err;
...@@ -310,7 +309,7 @@ static int register_vlan_device(struct net_device *real_dev, ...@@ -310,7 +309,7 @@ static int register_vlan_device(struct net_device *real_dev,
return err; return err;
/* Gotta set up the fields for the device. */ /* Gotta set up the fields for the device. */
switch (vlan_name_type) { switch (vn->name_type) {
case VLAN_NAME_TYPE_RAW_PLUS_VID: case VLAN_NAME_TYPE_RAW_PLUS_VID:
/* name will look like: eth1.0005 */ /* name will look like: eth1.0005 */
snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID); snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID);
...@@ -580,7 +579,10 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -580,7 +579,10 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
break; break;
if ((args.u.name_type >= 0) && if ((args.u.name_type >= 0) &&
(args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) { (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
vlan_name_type = args.u.name_type; struct vlan_net *vn;
vn = net_generic(net, vlan_net_id);
vn->name_type = args.u.name_type;
err = 0; err = 0;
} else { } else {
err = -EINVAL; err = -EINVAL;
...@@ -642,6 +644,8 @@ static int vlan_init_net(struct net *net) ...@@ -642,6 +644,8 @@ static int vlan_init_net(struct net *net)
if (err < 0) if (err < 0)
goto err_assign; goto err_assign;
vn->name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
err = vlan_proc_init(net); err = vlan_proc_init(net);
if (err < 0) if (err < 0)
goto err_proc; goto err_proc;
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
extern unsigned short vlan_name_type;
#define VLAN_GRP_HASH_SHIFT 5 #define VLAN_GRP_HASH_SHIFT 5
#define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT) #define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT)
#define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1) #define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1)
...@@ -59,6 +57,8 @@ struct vlan_net { ...@@ -59,6 +57,8 @@ struct vlan_net {
struct proc_dir_entry *proc_vlan_dir; struct proc_dir_entry *proc_vlan_dir;
/* /proc/net/vlan/config */ /* /proc/net/vlan/config */
struct proc_dir_entry *proc_vlan_conf; struct proc_dir_entry *proc_vlan_conf;
/* Determines interface naming scheme. */
unsigned short name_type;
}; };
#endif /* !(__BEN_VLAN_802_1Q_INC__) */ #endif /* !(__BEN_VLAN_802_1Q_INC__) */
...@@ -260,13 +260,16 @@ static void vlan_seq_stop(struct seq_file *seq, void *v) ...@@ -260,13 +260,16 @@ static void vlan_seq_stop(struct seq_file *seq, void *v)
static int vlan_seq_show(struct seq_file *seq, void *v) static int vlan_seq_show(struct seq_file *seq, void *v)
{ {
struct net *net = seq_file_net(seq);
struct vlan_net *vn = net_generic(net, vlan_net_id);
if (v == SEQ_START_TOKEN) { if (v == SEQ_START_TOKEN) {
const char *nmtype = NULL; const char *nmtype = NULL;
seq_puts(seq, "VLAN Dev name | VLAN ID\n"); seq_puts(seq, "VLAN Dev name | VLAN ID\n");
if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str)) if (vn->name_type < ARRAY_SIZE(vlan_name_type_str))
nmtype = vlan_name_type_str[vlan_name_type]; nmtype = vlan_name_type_str[vn->name_type];
seq_printf(seq, "Name-Type: %s\n", seq_printf(seq, "Name-Type: %s\n",
nmtype ? nmtype : "UNKNOWN"); nmtype ? nmtype : "UNKNOWN");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment