aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2011-07-15 18:48:46 +0100
committerMichael Brown <mcb30@ipxe.org>2011-07-15 18:48:46 +0100
commita667bf044a37f9e96830f1f35627829860f7019f (patch)
treefabf3420f244fd35ed3576169db8cf0cd706dd9f /src/net
parent69b7d57265679d76e26581d034e8f8ab5168bb27 (diff)
downloadipxe-a667bf044a37f9e96830f1f35627829860f7019f.tar.gz
[netdevice] Allow link layer to report broadcast/multicast packets via pull()
Allow the link layer to directly report whether or not a packet is multicast or broadcast at the time of calling pull(), rather than relying on heuristics to determine this at a later stage. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/80211/net80211.c10
-rw-r--r--src/net/aoe.c5
-rw-r--r--src/net/arp.c4
-rw-r--r--src/net/eapol.c4
-rw-r--r--src/net/eth_slow.c4
-rw-r--r--src/net/ethernet.c8
-rw-r--r--src/net/fcoe.c8
-rw-r--r--src/net/ipv4.c13
-rw-r--r--src/net/ipv6.c4
-rw-r--r--src/net/netdevice.c12
-rw-r--r--src/net/rarp.c4
-rw-r--r--src/net/vlan.c7
12 files changed, 60 insertions, 23 deletions
diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c
index 466d1243e..c00363cd2 100644
--- a/src/net/80211/net80211.c
+++ b/src/net/80211/net80211.c
@@ -135,7 +135,8 @@ static int net80211_ll_push ( struct net_device *netdev,
const void *ll_source, uint16_t net_proto );
static int net80211_ll_pull ( struct net_device *netdev,
struct io_buffer *iobuf, const void **ll_dest,
- const void **ll_source, uint16_t * net_proto );
+ const void **ll_source, uint16_t * net_proto,
+ unsigned int *flags );
/** @} */
/**
@@ -529,6 +530,7 @@ static int net80211_ll_push ( struct net_device *netdev,
* @ret ll_dest Link-layer destination address
* @ret ll_source Link-layer source
* @ret net_proto Network-layer protocol, in network byte order
+ * @ret flags Packet flags
* @ret rc Return status code
*
* This expects and removes both the 802.11 frame header and the 802.2
@@ -537,7 +539,7 @@ static int net80211_ll_push ( struct net_device *netdev,
static int net80211_ll_pull ( struct net_device *netdev __unused,
struct io_buffer *iobuf,
const void **ll_dest, const void **ll_source,
- uint16_t * net_proto )
+ uint16_t * net_proto, unsigned int *flags )
{
struct ieee80211_frame *hdr = iobuf->data;
struct ieee80211_llc_snap_header *lhdr =
@@ -586,6 +588,10 @@ static int net80211_ll_pull ( struct net_device *netdev __unused,
*ll_dest = hdr->addr1;
*ll_source = hdr->addr3;
*net_proto = lhdr->ethertype;
+ *flags = ( ( is_multicast_ether_addr ( hdr->addr1 ) ?
+ LL_MULTICAST : 0 ) |
+ ( is_broadcast_ether_addr ( hdr->addr1 ) ?
+ LL_BROADCAST : 0 ) );
return 0;
}
diff --git a/src/net/aoe.c b/src/net/aoe.c
index 3b1953a2f..1016b2509 100644
--- a/src/net/aoe.c
+++ b/src/net/aoe.c
@@ -906,13 +906,14 @@ static int aoedev_open ( struct interface *parent, struct net_device *netdev,
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
- *
*/
static int aoe_rx ( struct io_buffer *iobuf,
struct net_device *netdev __unused,
const void *ll_dest __unused,
- const void *ll_source ) {
+ const void *ll_source,
+ unsigned int flags __unused ) {
struct aoehdr *aoehdr = iobuf->data;
struct aoe_command *aoecmd;
int rc;
diff --git a/src/net/arp.c b/src/net/arp.c
index 9b5fd220e..ef30d5ecd 100644
--- a/src/net/arp.c
+++ b/src/net/arp.c
@@ -186,6 +186,7 @@ static struct arp_net_protocol * arp_find_protocol ( uint16_t net_proto ) {
* @v iobuf I/O buffer
* @v netdev Network device
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
*
* This handles ARP requests and responses as detailed in RFC826. The
@@ -196,7 +197,8 @@ static struct arp_net_protocol * arp_find_protocol ( uint16_t net_proto ) {
*/
static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
const void *ll_dest __unused,
- const void *ll_source __unused ) {
+ const void *ll_source __unused,
+ unsigned int flags __unused ) {
struct arphdr *arphdr = iobuf->data;
struct arp_net_protocol *arp_net_protocol;
struct net_protocol *net_protocol;
diff --git a/src/net/eapol.c b/src/net/eapol.c
index 9e5f26401..dd0420839 100644
--- a/src/net/eapol.c
+++ b/src/net/eapol.c
@@ -38,11 +38,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
*
* This function takes ownership of the I/O buffer passed to it.
*/
static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
- const void *ll_dest, const void *ll_source ) {
+ const void *ll_dest, const void *ll_source,
+ unsigned int flags __unused ) {
struct eapol_frame *eapol = iob->data;
struct eapol_handler *handler;
diff --git a/src/net/eth_slow.c b/src/net/eth_slow.c
index 9e68939cf..593e45bc1 100644
--- a/src/net/eth_slow.c
+++ b/src/net/eth_slow.c
@@ -234,12 +234,14 @@ static int eth_slow_marker_rx ( struct io_buffer *iobuf,
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
*/
static int eth_slow_rx ( struct io_buffer *iobuf,
struct net_device *netdev,
const void *ll_dest __unused,
- const void *ll_source __unused ) {
+ const void *ll_source __unused,
+ unsigned int flags __unused ) {
union eth_slow_packet *eth_slow = iobuf->data;
/* Sanity checks */
diff --git a/src/net/ethernet.c b/src/net/ethernet.c
index d14cfefcc..c63fd9bc3 100644
--- a/src/net/ethernet.c
+++ b/src/net/ethernet.c
@@ -71,11 +71,13 @@ static int eth_push ( struct net_device *netdev __unused,
* @ret ll_dest Link-layer destination address
* @ret ll_source Source link-layer address
* @ret net_proto Network-layer protocol, in network-byte order
+ * @ret flags Packet flags
* @ret rc Return status code
*/
static int eth_pull ( struct net_device *netdev __unused,
struct io_buffer *iobuf, const void **ll_dest,
- const void **ll_source, uint16_t *net_proto ) {
+ const void **ll_source, uint16_t *net_proto,
+ unsigned int *flags ) {
struct ethhdr *ethhdr = iobuf->data;
/* Sanity check */
@@ -92,6 +94,10 @@ static int eth_pull ( struct net_device *netdev __unused,
*ll_dest = ethhdr->h_dest;
*ll_source = ethhdr->h_source;
*net_proto = ethhdr->h_protocol;
+ *flags = ( ( is_multicast_ether_addr ( ethhdr->h_dest ) ?
+ LL_MULTICAST : 0 ) |
+ ( is_broadcast_ether_addr ( ethhdr->h_dest ) ?
+ LL_BROADCAST : 0 ) );
return 0;
}
diff --git a/src/net/fcoe.c b/src/net/fcoe.c
index db2fc9806..c54d1b474 100644
--- a/src/net/fcoe.c
+++ b/src/net/fcoe.c
@@ -331,10 +331,12 @@ static struct io_buffer * fcoe_alloc_iob ( struct fcoe_port *fcoe __unused,
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
*/
static int fcoe_rx ( struct io_buffer *iobuf, struct net_device *netdev,
- const void *ll_dest, const void *ll_source ) {
+ const void *ll_dest, const void *ll_source,
+ unsigned int flags __unused ) {
struct fcoe_header *fcoehdr;
struct fcoe_footer *fcoeftr;
struct fcoe_port *fcoe;
@@ -924,12 +926,14 @@ static struct fip_handler fip_handlers[] = {
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
*/
static int fcoe_fip_rx ( struct io_buffer *iobuf,
struct net_device *netdev,
const void *ll_dest,
- const void *ll_source __unused ) {
+ const void *ll_source __unused,
+ unsigned int flags __unused ) {
struct fip_header *fiphdr = iobuf->data;
struct fip_descriptors descs;
struct fip_handler *handler;
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 5bb48f61c..01eca09d8 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -381,10 +381,12 @@ static int ipv4_tx ( struct io_buffer *iobuf,
/**
* Process incoming packets
*
- * @v iobuf I/O buffer
- * @v netdev Network device
- * @v ll_dest Link-layer destination address
- * @v ll_source Link-layer destination source
+ * @v iobuf I/O buffer
+ * @v netdev Network device
+ * @v ll_dest Link-layer destination address
+ * @v ll_source Link-layer destination source
+ * @v flags Packet flags
+ * @ret rc Return status code
*
* This function expects an IP4 network datagram. It processes the headers
* and sends it to the transport layer.
@@ -392,7 +394,8 @@ static int ipv4_tx ( struct io_buffer *iobuf,
static int ipv4_rx ( struct io_buffer *iobuf,
struct net_device *netdev __unused,
const void *ll_dest __unused,
- const void *ll_source __unused ) {
+ const void *ll_source __unused,
+ unsigned int flags __unused ) {
struct iphdr *iphdr = iobuf->data;
size_t hdrlen;
size_t len;
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 712aa49e5..57bf94d8d 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -288,13 +288,15 @@ static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
*
* This function processes a IPv6 packet
*/
static int ipv6_rx ( struct io_buffer *iobuf,
__unused struct net_device *netdev,
__unused const void *ll_dest,
- __unused const void *ll_source ) {
+ __unused const void *ll_source,
+ __unused unsigned int flags ) {
struct ip6_header *ip6hdr = iobuf->data;
union {
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 52ad82925..f5ec4191f 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -678,17 +678,19 @@ int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
* @v net_proto Network-layer protocol, in network-byte order
* @v ll_dest Destination link-layer address
* @v ll_source Source link-layer address
+ * @v flags Packet flags
* @ret rc Return status code
*/
int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
- uint16_t net_proto, const void *ll_dest, const void *ll_source ) {
+ uint16_t net_proto, const void *ll_dest, const void *ll_source,
+ unsigned int flags ) {
struct net_protocol *net_protocol;
/* Hand off to network-layer protocol, if any */
for_each_table_entry ( net_protocol, NET_PROTOCOLS ) {
if ( net_protocol->net_proto == net_proto )
return net_protocol->rx ( iobuf, netdev, ll_dest,
- ll_source );
+ ll_source, flags );
}
DBGC ( netdev, "NETDEV %s unknown network protocol %04x\n",
@@ -710,6 +712,7 @@ void net_poll ( void ) {
const void *ll_dest;
const void *ll_source;
uint16_t net_proto;
+ unsigned int flags;
int rc;
/* Poll and process each network device */
@@ -743,7 +746,8 @@ void net_poll ( void ) {
ll_protocol = netdev->ll_protocol;
if ( ( rc = ll_protocol->pull ( netdev, iobuf,
&ll_dest, &ll_source,
- &net_proto ) ) != 0 ) {
+ &net_proto,
+ &flags ) ) != 0 ) {
free_iob ( iobuf );
continue;
}
@@ -751,7 +755,7 @@ void net_poll ( void ) {
/* Hand packet to network layer */
if ( ( rc = net_rx ( iob_disown ( iobuf ), netdev,
net_proto, ll_dest,
- ll_source ) ) != 0 ) {
+ ll_source, flags ) ) != 0 ) {
/* Record error for diagnosis */
netdev_rx_err ( netdev, NULL, rc );
}
diff --git a/src/net/rarp.c b/src/net/rarp.c
index da67c459d..59cb1d07f 100644
--- a/src/net/rarp.c
+++ b/src/net/rarp.c
@@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @v netdev Network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
*
* This is a dummy method which simply discards RARP packets.
@@ -45,7 +46,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
static int rarp_rx ( struct io_buffer *iobuf,
struct net_device *netdev __unused,
const void *ll_dest __unused,
- const void *ll_source __unused ) {
+ const void *ll_source __unused,
+ unsigned int flags __unused ) {
free_iob ( iobuf );
return 0;
}
diff --git a/src/net/vlan.c b/src/net/vlan.c
index 9ac560f1e..2147f91c5 100644
--- a/src/net/vlan.c
+++ b/src/net/vlan.c
@@ -91,12 +91,13 @@ static int vlan_transmit ( struct net_device *netdev,
const void *ll_dest;
const void *ll_source;
uint16_t net_proto;
+ unsigned int flags;
int rc;
/* Strip link-layer header and preserve link-layer header fields */
ll_protocol = netdev->ll_protocol;
if ( ( rc = ll_protocol->pull ( netdev, iobuf, &ll_dest, &ll_source,
- &net_proto ) ) != 0 ) {
+ &net_proto, &flags ) ) != 0 ) {
DBGC ( netdev, "VLAN %s could not parse link-layer header: "
"%s\n", netdev->name, strerror ( rc ) );
return rc;
@@ -214,10 +215,12 @@ struct net_device * vlan_find ( struct net_device *trunk, unsigned int tag ) {
* @v trunk Trunk network device
* @v ll_dest Link-layer destination address
* @v ll_source Link-layer source address
+ * @v flags Packet flags
* @ret rc Return status code
*/
static int vlan_rx ( struct io_buffer *iobuf, struct net_device *trunk,
- const void *ll_dest, const void *ll_source ) {
+ const void *ll_dest, const void *ll_source,
+ unsigned int flags __unused ) {
struct vlan_header *vlanhdr = iobuf->data;
struct net_device *netdev;
struct ll_protocol *ll_protocol;