From f6d20bb0f4f4b09341fc6c349b427611bd0b8a4d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 31 May 2006 19:12:17 +0000 Subject: [PATCH] Put in a method to get the MAC address for the AoE target. (It's not elegant, but it works). --- src/net/aoe.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/net/aoe.c b/src/net/aoe.c index 0d59a977..198bbb55 100644 --- a/src/net/aoe.c +++ b/src/net/aoe.c @@ -188,6 +188,7 @@ static int aoe_rx_response ( struct aoe_session *aoe, struct aoehdr *aoehdr, static int aoe_rx ( struct pk_buff *pkb ) { struct aoehdr *aoehdr = pkb->data; unsigned int len = pkb_len ( pkb ); + struct ethhdr *ethhdr = pkb_push ( pkb, sizeof ( *ethhdr ) ); struct aoe_session *aoe; int rc = 0; @@ -213,9 +214,8 @@ static int aoe_rx ( struct pk_buff *pkb ) { continue; if ( ntohl ( aoehdr->tag ) != aoe->tag ) continue; - -#warning "Need a way to get the MAC address for future reference" - + memcpy ( aoe->target, ethhdr->h_source, + sizeof ( aoe->target ) ); rc = aoe_rx_response ( aoe, aoehdr, len ); break; } @@ -235,10 +235,20 @@ static int aoe_rx ( struct pk_buff *pkb ) { */ static int aoe_route ( const struct pk_buff *pkb __unused, struct net_header *nethdr ) { + struct aoehdr *aoehdr = pkb->data; + struct aoe_session *aoe; -#warning "Need a way to find out the MAC address" - nethdr->flags = PKT_FL_BROADCAST; - return 0; + list_for_each_entry ( aoe, &aoe_sessions, list ) { + if ( ( ntohs ( aoehdr->major ) == aoe->major ) && + ( aoehdr->minor == aoe->minor ) ) { + nethdr->flags = PKT_FL_RAW_ADDR; + memcpy ( nethdr->dest_net_addr, aoe->target, + sizeof ( aoe->target ) ); + return 0; + } + } + + return -EHOSTUNREACH; } /** AoE protocol */ @@ -257,6 +267,7 @@ NET_PROTOCOL ( aoe_protocol ); * @v aoe AoE session */ void aoe_open ( struct aoe_session *aoe ) { + memset ( aoe->target, 0xff, sizeof ( aoe->target ) ); list_add ( &aoe->list, &aoe_sessions ); }