LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 02-08-2013, 02:50 PM   #1
jnielsen7
LQ Newbie
 
Registered: Feb 2013
Posts: 23

Rep: Reputation: Disabled
Any source documentation for ifcfg VLAN id 'dot' device names?


If you have ever implemented the 802.1q VLAN protocol in Linux you quickly discover that in your ifcfg-* files (RHEL: /etc/sysconfig/network-scripts/ifcfg-ethX) you will have to use a dot or period, the '.', in the device name for the "DEVICE=" value (ex: DEVICE=eth0.20, which will create a subinterface on eth0 - which probably is not VLAN tagging - and will send all traffic over that subinterface with a VLAN id of 20). Also, alternately if you want simple subinterfaces without VLAN tagging you can just use a colon (ex: DEVICE=eth0:1). However aside from config HOWTOs and blogs (which all seems to be word-of-mouth and no-source-citation) this feature of Linux 802.1q tagging seems fairly undocumented and I have looked fairly extensively online for anything relevant (not to mention it is difficult to Google for a special character that you can only call 'dot'). I do not care if I have to look at source code but I would like to know where the syntax rules are (especially for delimiters) for what determines and creates the right "type" of interface based on the device ':' or '.' notation in the ifcfg-* files.

Also, it seems that there is an alternate way to assign vlans to interfaces with the vconfig tool, which makes me wonder if whatever parses the ifcfg-* files shares with it the same code underneath. The only other relevant piece of information that I've been able to find is that the kernel module 8021q seems to be involved ("lsmod | grep 8021q") and that sometimes NIC specific drivers which are also loaded into the kernel will use it (in the "Used by" column of lsmod). I've poked around in /proc/net/vlan/ but still cannot figure out what implements the '.' dot notation to indicate that it should create a VLAN.

Is there a man page that I missed or will I have to dig through source code?

Thanks,
Josh

Last edited by jnielsen7; 02-08-2013 at 02:58 PM.
 
Old 02-09-2013, 08:14 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 1,991

Rep: Reputation: Disabled
When you add a VLAN subinterface (with a dot and a number), you are indeed configuring 802.1q VLAN tagging. This is handled by the 8021q kernel module. Traffic sent to a VLAN subinterface will be sent out the parent interface with a 8021q header, and the VLAN tag always corresponds to the subinterface number.

The "interface:alias" format is just a way of adding layer 3 addresses to an existing interface. The "alias" part can be any alphanumeric string; eth0:0, wlan1:secondary and eth1.23:test2 are valid aliases of the eth0, wlan1 and eth1.23 interfaces respectively. Since it is possible to add and remove addresses with the ip addr add and ip addr del commands, the alias format is no longer required and, as I understand it, deprecated.

The vconfig command is not an alternate method of configuring a VLAN interface, it is the method. The ifcfg-* files are simply parsed by other scripts or tools, and in the end the vconfig command is run with the relevant parameters.

(At least that's how it used to work; it's entirely possible that more recent inventions like NetworkManager does this with a direct system call rather than relying on vconfig.)
 
1 members found this post helpful.
Old 02-11-2013, 09:18 AM   #3
jnielsen7
LQ Newbie
 
Registered: Feb 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Ser Olmy View Post
When you add a VLAN subinterface (with a dot and a number), you are indeed configuring 802.1q VLAN tagging. This is handled by the 8021q kernel module. Traffic sent to a VLAN subinterface will be sent out the parent interface with a 8021q header, and the VLAN tag always corresponds to the subinterface number.

The "interface:alias" format is just a way of adding layer 3 addresses to an existing interface. The "alias" part can be any alphanumeric string; eth0:0, wlan1:secondary and eth1.23:test2 are valid aliases of the eth0, wlan1 and eth1.23 interfaces respectively. Since it is possible to add and remove addresses with the ip addr add and ip addr del commands, the alias format is no longer required and, as I understand it, deprecated.

The vconfig command is not an alternate method of configuring a VLAN interface, it is the method. The ifcfg-* files are simply parsed by other scripts or tools, and in the end the vconfig command is run with the relevant parameters.

(At least that's how it used to work; it's entirely possible that more recent inventions like NetworkManager does this with a direct system call rather than relying on vconfig.)
Thank you, that is helpful information. I actually was not aware that what came after a colon was an alias, and I thought it had to be numeric, so that was informative. This is probably enough information for what I need, although I suppose as a fun project some time I could look for those "scripts or tools" that parse the ifcfg-* files.

Thanks again,
Josh
 
Old 07-26-2013, 12:49 PM   #4
jnielsen7
LQ Newbie
 
Registered: Feb 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
I have since found a small bit of documentation for the interface:alias colon delimited notation in the Kernel source documentation in the Documentation/networking/alias.txt file: https://www.kernel.org/doc/Documenta...king/alias.txt. It also says there that is is deprecated but is maintained/allowed for backwards compatability.

As for VLAN tagging on interfaces using the dot notation in device names of /etc/sysconfig/network-scripts/ifcfg-* configuration files:

It appears that the dot notation in the network device is indeed specified/implemented in the code for the the 8021q kernel module itself, and whatever parses the ifcfg-* files (I still don't know that does that - where is that code?) is meant to find/expect a "device=eth[X].[VID]" name for the network interface - otherwise the kernel module could not use it.

From this page (http://www.candelatech.com/~greear/vlan.html) the Release Notes for version 1.0.3 of the 8021q module notes the following:
  • One of those requests was to change the default naming scheme to eth0.5, for a VLAN of VID 5 on eth0. You can over-ride this naming behaviour with the vconfig tool.
It looks like previously there already was a "non-padded" vid version of this though (called VLAN_NAME_TYPE_RAW_PLUS_VID) like: eth0.0005 for VID 5 so I'm still not sure when the first decision was made to use a dot, but I think it primarily is made that way for the benefit of providing a delimiter in the kernel module's code in any case.

I downloaded that version of the code from that page and looked at the patch file and found the relevant code.

First an ENUM list of various name types/notations that are valid:

Code:
enum vlan_name_types {
        VLAN_NAME_TYPE_PLUS_VID, /* Name will look like:  vlan0005 */
        VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like:  eth1.0005 */
        VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like:  vlan5 */
        VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like:  eth0.5 */
        VLAN_NAME_TYPE_HIGHEST
};
Then it chooses the name type VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD as a default to have names like eth[X].[VID] (e.g. eth0.5):

Code:
/** These may be changed at run-time through IOCTLs */
unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; /* determines interface naming scheme */
unsigned long vlan_bad_proto_recvd = 0; /* Counter for how many NON-VLAN protos we've received on a VLAN. */
Then here is the code that uses it in the register_802_1Q_vlan_device function/subroutine:

Code:
struct net_device *register_802_1Q_vlan_device(const char* eth_IF_name,
                                               unsigned short VLAN_ID) {
...
...

#ifdef VLAN_DEBUG
                                printk(VLAN_DBG "About to allocate name, vlan_name_type: %i\n", vlan_name_type);
#endif

 switch (vlan_name_type) {
                                   case VLAN_NAME_TYPE_RAW_PLUS_VID:
                                        /* name will look like:  eth1.0005 */
                                        sprintf(new_dev->name, "%s.%.4i", real_dev->name, VLAN_ID);
                                        break;
                                   case VLAN_NAME_TYPE_PLUS_VID_NO_PAD:
                                        /* Put our vlan.VID in the name.
                                           Name will look like:  vlan5 */
                                        sprintf(new_dev->name, "vlan%i", VLAN_ID);
                                        break;
                                   case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
                                        /* Put our vlan.VID in the name.
                                           Name will look like:  eth0.5 */
                                        sprintf(new_dev->name, "%s.%i", real_dev->name, VLAN_ID);
                                        break;
                                   case VLAN_NAME_TYPE_PLUS_VID:
                                        /* Put our vlan.VID in the name.
                                           Name will look like:  vlan0005 */
                                   default:
                                        /* default case */
                                        sprintf(new_dev->name, "vlan%.4i", VLAN_ID);
                                }/* switch */

#ifdef VLAN_DEBUG
                                printk(VLAN_DBG "Allocated new name -:%s:-\n", new_dev->name);
#endif
                                /* set up method calls */
                                new_dev->init = vlan_dev_init;
                                new_dev->destructor = vlan_dev_destruct;
            
                                /* new_dev->ifindex = 0;  it will be set when added to
                                 * the global list.
                                 * iflink is set as well. */
            
                                new_dev->get_stats = vlan_dev_get_stats;
            
                                /* IFF_BROADCAST|IFF_MULTICAST; ??? */
                                new_dev->flags = real_dev->flags;
                                new_dev->flags &= ~IFF_UP;

                                /* Make this thing known as a VLAN device */
                                new_dev->more_flags |= IFF_802_1Q_VLAN;

...
...
}
If anyone knows about any notes not interspersed in code, as to how the ifcfg-* files are parsed and the device name passed to vconfig, please let me know.

That's as far as I care to go for now into digging for the sources of those notations.

Last edited by jnielsen7; 08-01-2013 at 05:48 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use something not dot-local for AVAHI workstation names? SaintDanBert Linux - Networking 1 02-29-2012 01:08 PM
How to change ifcfg-ethX names to a new name like ifcfg-switchname rabbit1101 Linux - Newbie 3 12-14-2008 04:09 PM
fedora/redhat: ifcfg-eth0 and ifcfg-eth1 Shaun2222 Linux - Networking 9 01-23-2008 03:25 PM
Logical device names and instant names Gins Linux - General 8 11-30-2004 08:17 PM
User names with a dot? tplessers Linux - Newbie 20 08-29-2004 07:31 AM


All times are GMT -5. The time now is 05:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration