From owner-freebsd-net Wed Oct 7 06:31:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA18348 for freebsd-net-outgoing; Wed, 7 Oct 1998 06:31:11 -0700 (PDT) (envelope-from owner-freebsd-net@FreeBSD.ORG) Received: from mail.ftf.dk (mail.ftf.net [129.142.64.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA18343 for ; Wed, 7 Oct 1998 06:31:08 -0700 (PDT) (envelope-from regnauld@deepo.prosa.dk) Received: from mail.prosa.dk ([192.168.100.254]) by mail.ftf.dk (8.8.8/8.8.8/gw-ftf-1.0) with ESMTP id PAA25289 for ; Wed, 7 Oct 1998 15:36:14 +0200 (CEST) (envelope-from regnauld@deepo.prosa.dk) X-Authentication-Warning: mail.ftf.dk: Host [192.168.100.254] claimed to be mail.prosa.dk Received: from deepo.prosa.dk (deepo.prosa.dk [192.168.100.10]) by mail.prosa.dk (8.8.8/8.8.5/prosa-1.1) with ESMTP id PAA06997 for ; Wed, 7 Oct 1998 15:49:18 +0200 (CEST) Received: (from regnauld@localhost) by deepo.prosa.dk (8.8.8/8.8.5/prosa-1.1) id PAA20846; Wed, 7 Oct 1998 15:41:28 +0200 (CEST) Message-ID: <19981007154128.15689@deepo.prosa.dk> Date: Wed, 7 Oct 1998 15:41:28 +0200 From: Philippe Regnauld To: freebsd-net@FreeBSD.ORG Subject: Fwd: "linux 2.0.35 ip aliasing with aliased hwaddr" Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.88e X-Operating-System: FreeBSD 2.2.6-RELEASE i386 Phone: +45 3336 4148 Address: Ahlefeldtsgade 16, 1359 Copenhagen K, Denmark Organization: PROSA Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Would something similar be useful to have in FreeBSD ? -----Forwarded message from Mike Baker ----- From: Mike Baker 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 #include + #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