From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Patrick McHardy <kaber@trash.net>,
Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH net-2.6.26 8/10][VLAN]: Make the vlan_name_type per-net.
Date: Tue, 15 Apr 2008 16:15:22 +0400 [thread overview]
Message-ID: <48049C5A.60801@openvz.org> (raw)
In-Reply-To: <4804989F.1060503@openvz.org>
This includes moving one on the struct vlan_net and
s/vlan_name_type/vn->name_type/ over the code.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.c | 14 +++++++++-----
net/8021q/vlan.h | 4 ++--
net/8021q/vlanproc.c | 7 +++++--
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 541542e..5cacad0 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -52,9 +52,6 @@ static char vlan_version[] = DRV_VERSION;
static char vlan_copyright[] = "Ben Greear <greearb@candelatech.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 = {
.type = __constant_htons(ETH_P_8021Q),
.func = vlan_skb_recv, /* VLAN receive method */
@@ -299,6 +296,8 @@ static int register_vlan_device(struct net_device *real_dev,
unsigned short VLAN_ID)
{
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];
int err;
@@ -310,7 +309,7 @@ static int register_vlan_device(struct net_device *real_dev,
return err;
/* Gotta set up the fields for the device. */
- switch (vlan_name_type) {
+ switch (vn->name_type) {
case VLAN_NAME_TYPE_RAW_PLUS_VID:
/* name will look like: eth1.0005 */
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)
break;
if ((args.u.name_type >= 0) &&
(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;
} else {
err = -EINVAL;
@@ -642,6 +644,8 @@ static int vlan_init_net(struct net *net)
if (err < 0)
goto err_assign;
+ vn->name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
+
err = vlan_proc_init(net);
if (err < 0)
goto err_proc;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 7258357..5229a72 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -3,8 +3,6 @@
#include <linux/if_vlan.h>
-extern unsigned short vlan_name_type;
-
#define VLAN_GRP_HASH_SHIFT 5
#define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT)
#define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1)
@@ -59,6 +57,8 @@ struct vlan_net {
struct proc_dir_entry *proc_vlan_dir;
/* /proc/net/vlan/config */
struct proc_dir_entry *proc_vlan_conf;
+ /* Determines interface naming scheme. */
+ unsigned short name_type;
};
#endif /* !(__BEN_VLAN_802_1Q_INC__) */
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index cc17b72..daad006 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -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)
{
+ struct net *net = seq_file_net(seq);
+ struct vlan_net *vn = net_generic(net, vlan_net_id);
+
if (v == SEQ_START_TOKEN) {
const char *nmtype = NULL;
seq_puts(seq, "VLAN Dev name | VLAN ID\n");
- if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str))
- nmtype = vlan_name_type_str[vlan_name_type];
+ if (vn->name_type < ARRAY_SIZE(vlan_name_type_str))
+ nmtype = vlan_name_type_str[vn->name_type];
seq_printf(seq, "Name-Type: %s\n",
nmtype ? nmtype : "UNKNOWN");
--
1.5.3.4
next prev parent reply other threads:[~2008-04-15 11:41 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
2008-04-15 12:01 ` [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister Pavel Emelyanov
2008-04-15 12:00 ` Patrick McHardy
2008-04-15 12:03 ` [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper Pavel Emelyanov
2008-04-15 12:01 ` Patrick McHardy
2008-04-15 12:05 ` [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex Pavel Emelyanov
2008-04-15 12:03 ` Patrick McHardy
2008-04-15 12:07 ` [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops Pavel Emelyanov
2008-04-15 12:09 ` Patrick McHardy
2008-04-15 12:50 ` Pavel Emelyanov
2008-04-15 12:24 ` Patrick McHardy
2008-04-15 12:09 ` [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls Pavel Emelyanov
2008-04-15 12:26 ` Patrick McHardy
2008-04-15 13:05 ` Pavel Emelyanov
2008-04-15 12:31 ` Patrick McHardy
2008-04-15 12:12 ` [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net Pavel Emelyanov
2008-04-15 12:28 ` Patrick McHardy
2008-04-15 12:13 ` [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info Pavel Emelyanov
2008-04-15 12:28 ` Patrick McHardy
2008-04-15 12:15 ` Pavel Emelyanov [this message]
2008-04-15 12:17 ` [PATCH net-2.6.26 9/10][VLAN]: Allow vlan devices registration in net namespaces Pavel Emelyanov
2008-04-15 12:19 ` [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing Pavel Emelyanov
2008-04-15 12:30 ` Patrick McHardy
2008-04-16 8:02 ` [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48049C5A.60801@openvz.org \
--to=xemul@openvz.org \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).