[quagga-dev 1344] Re: 802.1q vlan questions

Paul Jakma paul at clubi.ie
Fri Jul 9 15:22:00 BST 2004


On Fri, 9 Jul 2004, mikeliu wrote:

> Dear All,
>
> I have a question about how to sync the interface infos via netlink 
> while adding a new vlan module on linux machine. The initial 
> runnning config I have is as follows,

> It should configure vlan 2 (sw0.2)'s ip address, not vlan 1 (sw0)'s 
> ip address. Did I miss something? It is highly appreciated that if 
> any of you could kindly help me out.

Try using the vlanX naming style, or any other naming style allowed 
by vlans.

It's possibly a bug in whatever VLAN layer you're using though, 
possibly setting IFLA_IFNAME to sw0 rather than sw0.1. Otherwise it's 
a bug in lib/if.c::if_cmp_func which potentially has been fixed in 
CVS, see [quagga-dev 1308]


> Thank you so much!
>
>
> Mike
>
>
> ------------------------------------------------------------------------------------------
> DEFUN (zebra_interface_vlan,
>       zebra_interface_vlan_cmd,
>       "interface vlan VLAN-ID",
>       "Select an interface to configure\n"
>       "Select a vlan to configure\n"
>       "Vlan's id\n")
> {

interesting ;)

>   int fd;
>   struct vlan_ioctl_args if_request;
>   struct interface * ifp;  // 11/03/03 mikeliu
>   char vlan_name[20];  // 11/03/03 mikeliu
>   char* cmd = "add";  // ADD_VLAN_CMD
>   char* if_name = "sw0";
>   unsigned int vid = 0;
>   char* conf_file_name = "/proc/net/vlan/config";
>
>   memset(&if_request, 0, sizeof(struct vlan_ioctl_args));
>
>   if(strlen(if_name) > 15) {
>      vty_out(vty, "ERROR: if_name must be 15 characters or less.%s", VTY_NEWLINE);
>      return CMD_WARNING;
>   }
>   strcpy(if_request.device1, if_name);
>
>   vid = atoi(argv[0]);
>   if_request.u.VID = vid;
>
>   // 11/03/03 mikeliu
>   if (vid == 1)
>      sprintf(vlan_name, "%s", if_name);
>   else
>      sprintf(vlan_name, "%s.%d", if_name, vid);
>
>   ifp = if_lookup_by_name (vlan_name);
>
>   if (ifp == NULL || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
>    {
>      if (ifp == NULL){
>
>        // Open up the /proc/vlan/config
>        if ((fd = open(conf_file_name, O_RDONLY)) < 0) {
>             vty_out(vty, "WARNING:  Could not open /proc/net/vlan/config.  Maybe you need to load the 8021q module, or      maybe you are not using PROCFS??%s",   VTY_NEWLINE);
>        }
>        else {
>           close(fd);
>        }
>
>        /* We use sockets now, instead of the file descriptor */
>        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
>           vty_out(vty, "FATAL:  Couldn't open a socket..go figure!%s", VTY_NEWLINE);
>        }
>
>        /* add */
>        if (strcasecmp(cmd, "add") == 0) {
>           if_request.cmd = ADD_VLAN_CMD;
>           if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
>             vty_out(vty, "ERROR: trying to add VLAN #%u to IF -:%s:-  error: %s%s", vid, if_name, strerror(errno), VTY_NEWLINE);
>           } else {
>
>             vty_out(vty, "Added VLAN with VID == %u to IF -:%s:- %s", vid, if_name, VTY_NEWLINE);
>             ifp = if_get_by_name (vlan_name);
>
>             /* If new link is added. */
>             if_add_update(ifp);
>
>           }
>        }
>     }
>   }
>   vty->index = ifp;
>   vty->node = INTERFACE_NODE;
>
>   vty_out(vty, "interface %s's index is %d%s", ifp->name, ifp->ifindex, VTY_NEWLINE);
>
>   return CMD_SUCCESS;
> }

I'm not sure we want to go down the road of configuring vlans 
though...

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
 	warning: do not ever send email to spam at dishone.st
Fortune:
Eat right, stay fit, and die anyway.



More information about the Quagga-dev mailing list