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

mikeliu mikeliu at nmi.iii.org.tw
Mon Jul 12 12:00:12 BST 2004


----- Original Message -----
From: "Paul Jakma" <paul at clubi.ie>
To: "mikeliu" <mikeliu at nmi.iii.org.tw>
Cc: <quagga-dev at lists.quagga.net>
Sent: Friday, July 09, 2004 10:22 PM
Subject: [quagga-dev 1344] Re: 802.1q vlan questions


> 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.

VLAN layer seems correct because "ifconfig" shows interface info correctly.

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 iB)  TX bytes:0 (0.0 iB)

sw0       Link encap:Ethernet  HWaddr 00:90:27:57:1B:00
          inet addr:192.168.8.120  Bcast:192.168.8.127  Mask:255.255.255.128
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 iB)  TX bytes:0 (0.0 iB)
          Interrupt:2 Base address:0xe000

sw0.2     Link encap:Ethernet  HWaddr 00:90:27:57:1B:00
          inet addr:130.233.235.1  Bcast:130.233.235.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 iB)  TX bytes:0 (0.0 iB)

>Otherwise it's
> a bug in lib/if.c::if_cmp_func which potentially has been fixed in
> CVS, see [quagga-dev 1308]

Before configuring ip info on a newly created vlan interface, switching
among different vlans works fine. It possibly means if_lookup_by_name is
okey. However, after configuing ip info on vlan 2,  "show interface" shows 2
interface sw0 as follows and zlog shows "000/01/01 00:01:58 ZEBRA: interface
sw0.2 is still created by netlink!". This log info is really stange since
interface sw0.2 should already exist.

int netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h){
...
...
/* Add interface. */
  if (h->nlmsg_type == RTM_NEWLINK)
    {
      ifp = if_lookup_by_name (name);

      if (ifp == NULL || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
 {
   if (ifp == NULL){
     ifp = if_get_by_name (name);
            zlog (NULL, LOG_WARNING, "interface %s is still created by
netlink!", ifp->name); //mikeliu debug
            printf("interface %s is created by netlink!\n", ifp->name);
   }
   ifp->ifindex = ifi->ifi_index;
   ifp->flags = ifi->ifi_flags & 0x0000fffff;
   ifp->mtu = *(int *)RTA_DATA (tb[IFLA_MTU]);
   ifp->metric = 1;

   /* If new link is added. */
   if_add_update(ifp);
 }
...
}


Router# sh interface
Interface lo
  index 1 metric 1 mtu 16436 <UP,LOOPBACK,RUNNING>
 interface is up
    input packets 0, bytes 0, dropped 0, multicast packets 0
    input errors 0, length 0, overrun 0, CRC 0, frame 0, fifo 0, missed 0
    output packets 0, bytes 0, dropped 0
    output errors 0, aborted 0, carrier 0, fifo 0, heartbeat 0, window 0
    collisions 0
Interface sw0
  index 2 metric 1 mtu 1500 <UP,BROADCAST,RUNNING,MULTICAST>
  HWaddr: 00:90:27:57:1b:00
 interface is up
    input packets 0, bytes 0, dropped 0, multicast packets 0
    input errors 0, length 0, overrun 0, CRC 0, frame 0, fifo 0, missed 0
    output packets 0, bytes 0, dropped 0
    output errors 0, aborted 0, carrier 0, fifo 0, heartbeat 0, window 0
    collisions 0
Interface sw0
  index 3 metric 1 mtu 1500 <UP,BROADCAST,RUNNING,MULTICAST>
 interface is up
    input packets 0, bytes 0, dropped 0, multicast packets 0
    input errors 0, length 0, overrun 0, CRC 0, frame 0, fifo 0, missed 0
    output packets 0, bytes 0, dropped 0
    output errors 0, aborted 0, carrier 0, fifo 0, heartbeat 0, window 0
    collisions 0
Interface sw0.2
  index 3 metric 1 mtu 1500 <UP,BROADCAST,RUNNING,MULTICAST>
 interface is up
    input packets 0, bytes 0, dropped 0, multicast packets 0
    input errors 0, length 0, overrun 0, CRC 0, frame 0, fifo 0, missed 0
    output packets 0, bytes 0, dropped 0
    output errors 0, aborted 0, carrier 0, fifo 0, heartbeat 0, window 0
    collisions 0


Any other clues are highly appreciated!

ps. if_cmp_func wasn't used by this CLI.


> > 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.
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev at lists.quagga.net
> http://lists.quagga.net/mailman/listinfo/quagga-dev




More information about the Quagga-dev mailing list