[Xorp-users] VLAN Interfaces

Joe Coco jcoco at meccorp.mec.edu
Mon Feb 14 08:15:54 PST 2011


Hello,


> Please post your current patch, and the simplest xorp-config test case that
> you can think of.  I should have time to look at this today if all goes
> as planned.
>
>Thanks,
>Ben



Ok. It's mainly some printing for debug. I commented out where it initializes vlan type until I can make a proper fix as you can see so we can do traditional dev.vlan. I.e, google searchers don't even think of applying this it's _WRONG_. 
 


Config:

   interfaces {
        interface eth1 {
            vif "eth1.100" {
                disable: false
                vlan {
                    vlan-id: 100
                }
                address 1.1.1.1 {
                    prefix-length: 24
                    disable: false
                }
            }
        }
    }


Step by step of config:

# create interfaces interface eth1 disable false
# create interfaces interface eth1 vif eth1.100 vlan vlan-id 100
# create interfaces interface eth1 vif eth1.100 address 1.1.1.1 prefix-length 24
# commit


ugly patch:

--- fea/data_plane/ifconfig/ifconfig_set_netlink_socket.cc-orig 2010-12-08 15:12:48.000000000 -0500
+++ fea/data_plane/ifconfig/ifconfig_set_netlink_socket.cc      2011-02-14 10:52:11.000000000 -0500
@@ -985,6 +985,12 @@

     memset(&buffer, 0, sizeof(buffer));

+/* Just to make sure nothing got lost or fouled up. This should print dev, followed by dev.vlan */
+
+fprintf(stderr, "-JC- add_addr called with  ifname: %s\n", ifname.c_str());
+fprintf(stderr, "-JC- add_addr called with vifname: %s\n", vifname.c_str());
+
+
     // Set the socket
     memset(&snl, 0, sizeof(snl));
     snl.nl_family = AF_NETLINK;
--- fea/data_plane/ifconfig/ifconfig_vlan_set_linux.cc-orig     2010-12-08 15:12:48.000000000 -0500
+++ fea/data_plane/ifconfig/ifconfig_vlan_set_linux.cc  2011-02-14 10:51:06.000000000 -0500
@@ -200,19 +200,27 @@
 {
     struct vlan_ioctl_args vlanreq;

+char tmpsystem[32];
+
     //
     // Set the VLAN interface naming
     //
-    memset(&vlanreq, 0, sizeof(vlanreq));
-    vlanreq.u.name_type = VLAN_NAME_TYPE_PLUS_VID_NO_PAD;      // vlan10
-    vlanreq.cmd = SET_VLAN_NAME_TYPE_CMD;
-    if (ioctl(_s4, SIOCSIFVLAN, &vlanreq) < 0) {
-       error_msg = c_format("Cannot set the VLAN interface name type"
-                            "to %s: %s",
-                            "VLAN_NAME_TYPE_PLUS_VID_NO_PAD",
-                            strerror(errno));
-       return (XORP_ERROR);
-    }
+//    memset(&vlanreq, 0, sizeof(vlanreq));
+//    vlanreq.u.name_type = DEV_PLUS_VID; /* eth1.100 */
+//    vlanreq.cmd = SET_VLAN_NAME_TYPE_CMD;
+//    if (ioctl(_s4, SIOCSIFVLAN, &vlanreq) < 0) {
+//     error_msg = c_format("Cannot set the VLAN interface name type"
+//                          "to %s: %s",
+//                          "VLAN_NAME_TYPE_PLUS_VID_NO_PAD",
+//                          strerror(errno));
+//     return (XORP_ERROR);
+  //  }
+
+/* This is a temporary hack/joke. Really, for now just use Ben's vconfig with the intention of fixing
+   the above code to be dev_plus_vif like most linux (other than zebos) - JC */
+
+system("/sbin/vconfig set_name_type DEV_PLUS_VID_NO_PAD");
+

     //
     // Create the VLAN
@@ -229,10 +237,18 @@
        return (XORP_ERROR);
     }

+fprintf(stderr, "-JC- Created vlan device: %s \n", vlan_name.c_str()); /* -JC */
+
     //
     // Rename the VLAN interface if necessary
     //
-    string tmp_vlan_name = c_format("vlan%u", vlan_id);
+//    string tmp_vlan_name = c_format("vlan%u", vlan_id);
+
+  string tmp_vlan_name = vlan_name.c_str();
+
+
+//c_format("%s.%u", parent_ifname.c_str(), vlan_id);
+

     if (vlan_name != tmp_vlan_name) {
 #ifndef SIOCSIFNAME
--- fea/data_plane/ifconfig/ifconfig_set.cc-orig        2010-12-08 15:12:48.000000000 -0500
+++ fea/data_plane/ifconfig/ifconfig_set.cc     2011-02-14 10:47:47.000000000 -0500
@@ -656,6 +656,10 @@
                               config_iface, config_vif, config_addr,
                               error_msg)
            != XORP_OK) {
+
+               fprintf(stderr, "-JC- push_vif_address - config_iface ifname: %s\n", config_iface.ifname().c_str());
+               fprintf(stderr, "-JC- push_vif_address - config_vif vifname: %s\n", config_vif.vifname().c_str());
+
            if (strstr(error_msg.c_str(), "No such device")) {
                XLOG_ERROR("Failed to configure address because of device not found: %s",
                           error_msg.c_str());





More information about the Xorp-users mailing list