Date: Wed, 7 Oct 1998 15:41:28 +0200 From: Philippe Regnauld <regnauld@deepo.prosa.dk> To: freebsd-net@FreeBSD.ORG Subject: Fwd: "linux 2.0.35 ip aliasing with aliased hwaddr" <mjbaker@CSLSERVER.CSL.MTU.EDU> Message-ID: <19981007154128.15689@deepo.prosa.dk>
next in thread | raw e-mail | index | archive | help
Would something similar be useful to have in FreeBSD ? -----Forwarded message from Mike Baker <mjbaker@CSLSERVER.CSL.MTU.EDU>----- From: Mike Baker <mjbaker@CSLSERVER.CSL.MTU.EDU> Subject: linux 2.0.35 ip aliasing with aliased hwaddr To: BUGTRAQ@NETSPACE.ORG Date: Tue, 6 Oct 1998 05:27:08 -0400 This is a multi-part message in MIME format. --------------290AB10A6E945601D147B27B Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --------------290AB10A6E945601D147B27B Content-Type: text/plain; charset=us-ascii; name="ipalias.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ipalias.diff" 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 --------------290AB10A6E945601D147B27B-- -----End of forwarded message----- -- -[ Philippe Regnauld / sysadmin / regnauld@deepo.prosa.dk / +55.4N +11.3E ]- The Internet is busy. Please try again later. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981007154128.15689>