From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [Qemu-devel] [PATCH 5/10] Add network announce function Date: Wed, 10 Sep 2008 17:00:12 +0300 Message-ID: <48C7D2EC.3080001@qumranet.com> References: <1220989802-13706-1-git-send-email-aliguori@us.ibm.com> <1220989802-13706-6-git-send-email-aliguori@us.ibm.com> <48C7CB28.2090707@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Chris Wright , Uri Lublin , Anthony Liguori , kvm@vger.kernel.org To: qemu-devel@nongnu.org Return-path: Received: from il.qumranet.com ([212.179.150.194]:52104 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751425AbYIJOAQ (ORCPT ); Wed, 10 Sep 2008 10:00:16 -0400 In-Reply-To: <48C7CB28.2090707@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Chris Lalancette wrote: > Anthony Liguori wrote: > >> +static int announce_self_create(uint8_t *buf, >> + uint8_t *mac_addr) >> +{ >> + uint32_t magic = EXPERIMENTAL_MAGIC; >> + uint16_t proto = htons(ETH_P_EXPERIMENTAL); >> + >> + /* FIXME: should we send a different packet (arp/rarp/ping)? */ >> + >> + memset(buf, 0xff, 6); /* h_dst */ >> + memcpy(buf + 6, mac_addr, 6); /* h_src */ >> + memcpy(buf + 12, &proto, 2); /* h_proto */ >> + memcpy(buf + 14, &magic, 4); /* magic */ >> + >> + return 18; /* len */ >> +} >> + >> +void qemu_announce_self(void) >> +{ >> + int i, j, len; >> + VLANState *vlan; >> + VLANClientState *vc; >> + uint8_t buf[256]; >> + >> + for (i = 0; i < nb_nics; i++) { >> + len = announce_self_create(buf, nd_table[i].macaddr); >> + vlan = nd_table[i].vlan; >> + for(vc = vlan->first_client; vc != NULL; vc = vc->next) { >> + if (vc->fd_read == tap_receive) /* send only if tap */ >> + for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++) >> + vc->fd_read(vc->opaque, buf, len); >> + } >> + } >> +} >> + >> > > This one is yucky, as the FIXME points out. First, I'm guessing the point of > this is to do an ARP poison on the switch? If so, we probably want to do some > kind of ARP packet, although I'm not an expert on this. ARP is to announce an IP address moving to a different MAC address. Here the MAC address stays the same, but we want to announce to the switch that the MAC address is moving to a different port. There may not even be an IP stack running in the guest, and we don't know the IP address(es) the guest is using, so I don't see how ARP fits here. Since switches learn the MAC address to port association, all we need is to send _some_ packet. > Also, why are we trying > SELF_ANNOUNCE_ROUNDS times? Is there some issue where some of these get > dropped, or is it just being safe about it Some switches drop the first packet; and if those switches are chained, we need to send multiple packets. -- error compiling committee.c: too many arguments to function