summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown2009-07-17 23:48:31 +0200
committerMichael Brown2009-07-18 00:02:48 +0200
commitd09290161e33574d8f0fa900ebe739214d17fe1a (patch)
tree9cb59387262344ed50fc755362154206017ab220 /src/net
parent[ata] Make ATA command issuing partially asynchronous (diff)
downloadipxe-d09290161e33574d8f0fa900ebe739214d17fe1a.tar.gz
ipxe-d09290161e33574d8f0fa900ebe739214d17fe1a.tar.xz
ipxe-d09290161e33574d8f0fa900ebe739214d17fe1a.zip
[netdevice] Make ll_broadcast per-netdevice rather than per-ll_protocol
IPoIB has a link-layer broadcast address that varies according to the partition key. We currently go through several contortions to pretend that the link-layer address is a fixed constant; by making the broadcast address a property of the network device rather than the link-layer protocol it will be possible to simplify IPoIB's broadcast handling.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/aoe.c3
-rw-r--r--src/net/arp.c2
-rw-r--r--src/net/ethernet.c19
-rw-r--r--src/net/ipv4.c2
4 files changed, 21 insertions, 5 deletions
diff --git a/src/net/aoe.c b/src/net/aoe.c
index f274ddf51..839a875b4 100644
--- a/src/net/aoe.c
+++ b/src/net/aoe.c
@@ -440,8 +440,7 @@ int aoe_attach ( struct ata_device *ata, struct net_device *netdev,
return -ENOMEM;
aoe->refcnt.free = aoe_free;
aoe->netdev = netdev_get ( netdev );
- memcpy ( aoe->target, ethernet_protocol.ll_broadcast,
- sizeof ( aoe->target ) );
+ memcpy ( aoe->target, netdev->ll_broadcast, sizeof ( aoe->target ) );
aoe->tag = AOE_TAG_MAGIC;
aoe->timer.expired = aoe_timer_expired;
diff --git a/src/net/arp.c b/src/net/arp.c
index 8bc83958a..124a856eb 100644
--- a/src/net/arp.c
+++ b/src/net/arp.c
@@ -156,7 +156,7 @@ int arp_resolve ( struct net_device *netdev, struct net_protocol *net_protocol,
/* Transmit ARP request */
if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
- ll_protocol->ll_broadcast ) ) != 0 )
+ netdev->ll_broadcast ) ) != 0 )
return rc;
return -ENOENT;
diff --git a/src/net/ethernet.c b/src/net/ethernet.c
index 6c5f7879d..5e2793f94 100644
--- a/src/net/ethernet.c
+++ b/src/net/ethernet.c
@@ -145,9 +145,26 @@ struct ll_protocol ethernet_protocol __ll_protocol = {
.ll_proto = htons ( ARPHRD_ETHER ),
.ll_addr_len = ETH_ALEN,
.ll_header_len = ETH_HLEN,
- .ll_broadcast = eth_broadcast,
.push = eth_push,
.pull = eth_pull,
.ntoa = eth_ntoa,
.mc_hash = eth_mc_hash,
};
+
+/**
+ * Allocate Ethernet device
+ *
+ * @v priv_size Size of driver private data
+ * @ret netdev Network device, or NULL
+ */
+struct net_device * alloc_etherdev ( size_t priv_size ) {
+ struct net_device *netdev;
+
+ netdev = alloc_netdev ( priv_size );
+ if ( netdev ) {
+ netdev->ll_protocol = &ethernet_protocol;
+ netdev->ll_broadcast = eth_broadcast;
+ netdev->max_pkt_len = ETH_FRAME_LEN;
+ }
+ return netdev;
+}
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 79fa9ea6e..64d294e54 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -271,7 +271,7 @@ static int ipv4_ll_addr ( struct in_addr dest, struct in_addr src,
if ( dest.s_addr == INADDR_BROADCAST ) {
/* Broadcast address */
- memcpy ( ll_dest, ll_protocol->ll_broadcast,
+ memcpy ( ll_dest, netdev->ll_broadcast,
ll_protocol->ll_addr_len );
return 0;
} else if ( IN_MULTICAST ( ntohl ( dest.s_addr ) ) ) {