linux 2.0.35 ip aliasing with aliased hwaddr (fwd)

T.Pospisek's MailLists tpo2 at spin.ch
Wed Oct 7 07:13:01 MDT 1998


Here is a kernel patch posted very recently on bugtraq. It is surely
interesting in fall-over scenarios.
*
t

             WANTED: sysadmin-> http://spin.ch/~tpo/joboffer
------------------------------------------------------------------------------
             Tomas Pospisek - Freelance: Linuxing, Networking
                      http://spin.ch/~tpo/freelance
         www.SPIN.ch - Internet Services in Graubuenden/Switzerland
------------------------------------------------------------------------------

---------- Forwarded message ----------
Date: Tue, 6 Oct 1998 05:27:08 -0400
From: Mike Baker <mjbaker at CSLSERVER.CSL.MTU.EDU>
To: BUGTRAQ at netspace.org
Subject: linux 2.0.35 ip aliasing with aliased hwaddr

Included is a small patch to linux 2.0.35 that allows each aliased
device to have it's own mac separate from that of the actual device and
other aliases, making your single network card look like several from
any other node on the network,

This patch was developed on linux 2.0.35 for use with ethernet devices,
it may not be compatible with all systems or hardware.

usage:

/sbin/ifconfig eth0:0 192.168.0.2
/sbin/ifconfig hw ether deadbeef0001

This patch will put the real device in promisc to allow it to receive
all packets then use the kernel's network driver to drop packets that
don't match any device.

-MbM
-------------- next part --------------
diff -u --recursive --new-file -w linux-2.0.35.orig/net/core/net_alias.c linux/net/core/net_alias.c
--- linux-2.0.35.orig/net/core/net_alias.c      Tue Aug 12 17:15:56 1997
+++ linux/net/core/net_alias.c  Sun Sep 20 21:28:13 1998
@@ -50,6 +50,7 @@
 #include <linux/stat.h>
 #include <linux/sysctl.h>

+
 #ifdef ALIAS_USER_LAND_DEBUG
 #include "net_alias.h"
 #include "user_stubs.h"
@@ -296,6 +297,19 @@
   return 0;
 }

+
+
+static int alias_mac_addr(struct device *dev, void *p)
+{
+        struct sockaddr *addr=p;
+        if(dev->start)
+                return -EBUSY;
+        memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
+        return 0;
+}
+
+
+
 /*
  * setups a new (alias) device
  */
@@ -329,7 +343,7 @@
   dev->open = net_alias_dev_open;
   dev->stop = net_alias_dev_close;
   dev->get_stats = net_alias_dev_stats;
-
+  dev->set_mac_address = alias_mac_addr;
   dev->hard_header_len = main_dev->hard_header_len;
   memcpy(dev->broadcast, main_dev->broadcast, MAX_ADDR_LEN);
   memcpy(dev->dev_addr, main_dev->dev_addr, MAX_ADDR_LEN);
@@ -337,6 +351,7 @@
   dev->init = net_alias_devinit;
   dev->hard_start_xmit = net_alias_hard_start_xmit;
   dev->flags = main_dev->flags & NET_ALIAS_IFF_MASK & ~IFF_UP;
+  main_dev->flags = main_dev->flags | IFF_PROMISC;

   /*
    * only makes sense if same family
@@ -1216,6 +1231,8 @@
   struct net_alias_info *alias_info;
   struct device *dev;

+
+
   if (main_dev == NULL) return NULL;

   /*
diff -u --recursive --new-file -w linux-2.0.35.orig/net/ethernet/eth.c linux/net/ethernet/eth.c
--- linux-2.0.35.orig/net/ethernet/eth.c        Wed Jun  3 18:17:50 1998
+++ linux/net/ethernet/eth.c    Wed Sep 30 14:07:01 1998
@@ -176,6 +176,7 @@
 {
        struct ethhdr *eth;
        unsigned char *rawp;
+       struct device *temp_dev;

        skb->mac.raw=skb->data;
        skb_pull(skb,dev->hard_header_len);
@@ -197,7 +198,19 @@
        else if(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))
        {
                if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN))
+               {
                        skb->pkt_type=PACKET_OTHERHOST;
+                       /* assume all aliases come after the real device */
+                       for(temp_dev = dev; temp_dev != NULL ; temp_dev = temp_dev->next)
+                               if(!memcmp(eth->h_dest,temp_dev->dev_addr, ETH_ALEN))
+                               {
+                                       skb->pkt_type=PACKET_HOST;
+                                       break;
+                               }
+
+
+
+               }
        }

        if (ntohs(eth->h_proto) >= 1536)
diff -u --recursive --new-file -w linux-2.0.35.orig/net/ipv4/arp.c linux/net/ipv4/arp.c
--- linux-2.0.35.orig/net/ipv4/arp.c    Mon Jul 13 16:47:41 1998
+++ linux/net/ipv4/arp.c        Wed Sep 30 14:07:24 1998
@@ -1771,6 +1771,12 @@
        unsigned char *sha,*tha;
        u32 sip,tip;

+        if(skb->pkt_type==PACKET_OTHERHOST)
+        {
+                kfree_skb(skb, FREE_READ);
+                return 0;
+        }
+
 /*
  *     The hardware length of the packet should match the hardware length
  *     of the device.  Similarly, the hardware types should match.  The
@@ -1894,6 +1900,9 @@
                kfree_skb(skb, FREE_READ);
                return 0;
        }
+
+
+

 /*
  *  Process entry.  The idea here is we want to send a reply if it is a


More information about the Linux-HA mailing list