[netdevice] Pass both link-layer addresses in net_tx() and net_rx()
FCoE requires the use of fabric-provided MAC addresses, which breaks the assumption that the net device's MAC address is implicitly the source address for net_tx() and the (unicast) destination address for net_rx(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
d57d49942a
commit
88dd921e24
|
@ -90,7 +90,8 @@ struct eapol_handler
|
||||||
*
|
*
|
||||||
* @v iob I/O buffer containing packet payload
|
* @v iob I/O buffer containing packet payload
|
||||||
* @v netdev Network device from which packet was received
|
* @v netdev Network device from which packet was received
|
||||||
* @v ll_source Source link-layer address from which packet was received
|
* @V ll_dest Destination link-layer address
|
||||||
|
* @v ll_source Source link-layer address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*
|
*
|
||||||
* The I/O buffer will have the EAPOL header pulled off it, so
|
* The I/O buffer will have the EAPOL header pulled off it, so
|
||||||
|
@ -99,7 +100,7 @@ struct eapol_handler
|
||||||
* This function takes ownership of the I/O buffer passed to it.
|
* This function takes ownership of the I/O buffer passed to it.
|
||||||
*/
|
*/
|
||||||
int ( * rx ) ( struct io_buffer *iob, struct net_device *netdev,
|
int ( * rx ) ( struct io_buffer *iob, struct net_device *netdev,
|
||||||
const void *ll_source );
|
const void *ll_dest, const void *ll_source );
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EAPOL_HANDLERS __table ( struct eapol_handler, "eapol_handlers" )
|
#define EAPOL_HANDLERS __table ( struct eapol_handler, "eapol_handlers" )
|
||||||
|
|
|
@ -57,12 +57,13 @@ struct net_protocol {
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
*
|
*
|
||||||
* This method takes ownership of the I/O buffer.
|
* This method takes ownership of the I/O buffer.
|
||||||
*/
|
*/
|
||||||
int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
|
int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
const void *ll_source );
|
const void *ll_dest, const void *ll_source );
|
||||||
/**
|
/**
|
||||||
* Transcribe network-layer address
|
* Transcribe network-layer address
|
||||||
*
|
*
|
||||||
|
@ -534,9 +535,11 @@ extern struct net_device * find_netdev_by_location ( unsigned int bus_type,
|
||||||
unsigned int location );
|
unsigned int location );
|
||||||
extern struct net_device * last_opened_netdev ( void );
|
extern struct net_device * last_opened_netdev ( void );
|
||||||
extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
struct net_protocol *net_protocol, const void *ll_dest );
|
struct net_protocol *net_protocol, const void *ll_dest,
|
||||||
|
const void *ll_source );
|
||||||
extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
uint16_t net_proto, const void *ll_source );
|
uint16_t net_proto, const void *ll_dest,
|
||||||
|
const void *ll_source );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete network transmission
|
* Complete network transmission
|
||||||
|
|
|
@ -455,7 +455,7 @@ static int wpa_send_eapol ( struct io_buffer *iob, struct wpa_common_ctx *ctx,
|
||||||
pkt->mic );
|
pkt->mic );
|
||||||
|
|
||||||
return net_tx ( iob, ctx->dev->netdev, &eapol_protocol,
|
return net_tx ( iob, ctx->dev->netdev, &eapol_protocol,
|
||||||
ctx->dev->bssid );
|
ctx->dev->bssid, ctx->dev->netdev->ll_addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -757,9 +757,11 @@ static int wpa_handle_1_of_2 ( struct wpa_common_ctx *ctx,
|
||||||
*
|
*
|
||||||
* @v iob I/O buffer
|
* @v iob I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Source link-layer address
|
* @v ll_source Source link-layer address
|
||||||
*/
|
*/
|
||||||
static int eapol_key_rx ( struct io_buffer *iob, struct net_device *netdev,
|
static int eapol_key_rx ( struct io_buffer *iob, struct net_device *netdev,
|
||||||
|
const void *ll_dest __unused,
|
||||||
const void *ll_source )
|
const void *ll_source )
|
||||||
{
|
{
|
||||||
struct net80211_device *dev = net80211_get ( netdev );
|
struct net80211_device *dev = net80211_get ( netdev );
|
||||||
|
|
|
@ -249,13 +249,14 @@ static void aoecmd_close ( struct aoe_command *aoecmd, int rc ) {
|
||||||
*/
|
*/
|
||||||
static int aoecmd_tx ( struct aoe_command *aoecmd ) {
|
static int aoecmd_tx ( struct aoe_command *aoecmd ) {
|
||||||
struct aoe_device *aoedev = aoecmd->aoedev;
|
struct aoe_device *aoedev = aoecmd->aoedev;
|
||||||
|
struct net_device *netdev = aoedev->netdev;
|
||||||
struct io_buffer *iobuf;
|
struct io_buffer *iobuf;
|
||||||
struct aoehdr *aoehdr;
|
struct aoehdr *aoehdr;
|
||||||
size_t cmd_len;
|
size_t cmd_len;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
assert ( aoedev->netdev != NULL );
|
assert ( netdev != NULL );
|
||||||
|
|
||||||
/* If we are transmitting anything that requires a response,
|
/* If we are transmitting anything that requires a response,
|
||||||
* start the retransmission timer. Do this before attempting
|
* start the retransmission timer. Do this before attempting
|
||||||
|
@ -281,8 +282,8 @@ static int aoecmd_tx ( struct aoe_command *aoecmd ) {
|
||||||
aoecmd->type->cmd ( aoecmd, iobuf->data, iob_len ( iobuf ) );
|
aoecmd->type->cmd ( aoecmd, iobuf->data, iob_len ( iobuf ) );
|
||||||
|
|
||||||
/* Send packet */
|
/* Send packet */
|
||||||
if ( ( rc = net_tx ( iobuf, aoedev->netdev, &aoe_protocol,
|
if ( ( rc = net_tx ( iobuf, netdev, &aoe_protocol, aoedev->target,
|
||||||
aoedev->target ) ) != 0 ) {
|
netdev->ll_addr ) ) != 0 ) {
|
||||||
DBGC ( aoedev, "AoE %s/%08x could not transmit: %s\n",
|
DBGC ( aoedev, "AoE %s/%08x could not transmit: %s\n",
|
||||||
aoedev_name ( aoedev ), aoecmd->tag,
|
aoedev_name ( aoedev ), aoecmd->tag,
|
||||||
strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
|
@ -903,12 +904,14 @@ static int aoedev_open ( struct interface *parent, struct net_device *netdev,
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int aoe_rx ( struct io_buffer *iobuf,
|
static int aoe_rx ( struct io_buffer *iobuf,
|
||||||
struct net_device *netdev __unused,
|
struct net_device *netdev __unused,
|
||||||
|
const void *ll_dest __unused,
|
||||||
const void *ll_source ) {
|
const void *ll_source ) {
|
||||||
struct aoehdr *aoehdr = iobuf->data;
|
struct aoehdr *aoehdr = iobuf->data;
|
||||||
struct aoe_command *aoecmd;
|
struct aoe_command *aoecmd;
|
||||||
|
|
|
@ -156,7 +156,7 @@ int arp_resolve ( struct net_device *netdev, struct net_protocol *net_protocol,
|
||||||
|
|
||||||
/* Transmit ARP request */
|
/* Transmit ARP request */
|
||||||
if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
|
if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
|
||||||
netdev->ll_broadcast ) ) != 0 )
|
netdev->ll_broadcast, netdev->ll_addr ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -195,6 +195,7 @@ static struct arp_net_protocol * arp_find_protocol ( uint16_t net_proto ) {
|
||||||
* details.
|
* details.
|
||||||
*/
|
*/
|
||||||
static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
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 ) {
|
||||||
struct arphdr *arphdr = iobuf->data;
|
struct arphdr *arphdr = iobuf->data;
|
||||||
struct arp_net_protocol *arp_net_protocol;
|
struct arp_net_protocol *arp_net_protocol;
|
||||||
|
@ -261,7 +262,7 @@ static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
|
|
||||||
/* Send reply */
|
/* Send reply */
|
||||||
net_tx ( iob_disown ( iobuf ), netdev, &arp_protocol,
|
net_tx ( iob_disown ( iobuf ), netdev, &arp_protocol,
|
||||||
arp_target_ha ( arphdr ) );
|
arp_target_ha ( arphdr ), netdev->ll_addr );
|
||||||
|
|
||||||
done:
|
done:
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
|
|
|
@ -36,13 +36,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
*
|
*
|
||||||
* @v iob I/O buffer
|
* @v iob I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
*
|
*
|
||||||
* This function takes ownership of the I/O buffer passed to it.
|
* This function takes ownership of the I/O buffer passed to it.
|
||||||
*/
|
*/
|
||||||
static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
|
static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
|
||||||
const void *ll_source )
|
const void *ll_dest, const void *ll_source ) {
|
||||||
{
|
|
||||||
struct eapol_frame *eapol = iob->data;
|
struct eapol_frame *eapol = iob->data;
|
||||||
struct eapol_handler *handler;
|
struct eapol_handler *handler;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
|
||||||
for_each_table_entry ( handler, EAPOL_HANDLERS ) {
|
for_each_table_entry ( handler, EAPOL_HANDLERS ) {
|
||||||
if ( handler->type == eapol->type ) {
|
if ( handler->type == eapol->type ) {
|
||||||
iob_pull ( iob, EAPOL_HDR_LEN );
|
iob_pull ( iob, EAPOL_HDR_LEN );
|
||||||
return handler->rx ( iob, netdev, ll_source );
|
return handler->rx ( iob, netdev, ll_dest, ll_source );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,8 @@ static int eth_slow_lacp_rx ( struct io_buffer *iobuf,
|
||||||
|
|
||||||
/* Send response */
|
/* Send response */
|
||||||
eth_slow_lacp_dump ( iobuf, netdev, "TX" );
|
eth_slow_lacp_dump ( iobuf, netdev, "TX" );
|
||||||
return net_tx ( iobuf, netdev, ð_slow_protocol, eth_slow_address );
|
return net_tx ( iobuf, netdev, ð_slow_protocol, eth_slow_address,
|
||||||
|
netdev->ll_addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,7 +219,7 @@ static int eth_slow_marker_rx ( struct io_buffer *iobuf,
|
||||||
marker->marker.tlv.type = ETH_SLOW_TLV_MARKER_RESPONSE;
|
marker->marker.tlv.type = ETH_SLOW_TLV_MARKER_RESPONSE;
|
||||||
eth_slow_marker_dump ( iobuf, netdev, "TX" );
|
eth_slow_marker_dump ( iobuf, netdev, "TX" );
|
||||||
return net_tx ( iobuf, netdev, ð_slow_protocol,
|
return net_tx ( iobuf, netdev, ð_slow_protocol,
|
||||||
eth_slow_address );
|
eth_slow_address, netdev->ll_addr );
|
||||||
} else {
|
} else {
|
||||||
/* Discard all other marker packets */
|
/* Discard all other marker packets */
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
|
@ -231,11 +232,13 @@ static int eth_slow_marker_rx ( struct io_buffer *iobuf,
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int eth_slow_rx ( struct io_buffer *iobuf,
|
static int eth_slow_rx ( struct io_buffer *iobuf,
|
||||||
struct net_device *netdev,
|
struct net_device *netdev,
|
||||||
|
const void *ll_dest __unused,
|
||||||
const void *ll_source __unused ) {
|
const void *ll_source __unused ) {
|
||||||
union eth_slow_packet *eth_slow = iobuf->data;
|
union eth_slow_packet *eth_slow = iobuf->data;
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ static int fcoe_deliver ( struct fcoe_port *fcoe,
|
||||||
|
|
||||||
/* Transmit packet */
|
/* Transmit packet */
|
||||||
if ( ( rc = net_tx ( iob_disown ( iobuf ), fcoe->netdev, &fcoe_protocol,
|
if ( ( rc = net_tx ( iob_disown ( iobuf ), fcoe->netdev, &fcoe_protocol,
|
||||||
fcoe->fcf_ll_addr ) ) != 0 ) {
|
fcoe->fcf_ll_addr, fcoe->netdev->ll_addr )) != 0){
|
||||||
DBGC ( fcoe, "FCoE %s could not transmit: %s\n",
|
DBGC ( fcoe, "FCoE %s could not transmit: %s\n",
|
||||||
fcoe->netdev->name, strerror ( rc ) );
|
fcoe->netdev->name, strerror ( rc ) );
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -164,12 +164,12 @@ static struct io_buffer * fcoe_alloc_iob ( struct fcoe_port *fcoe __unused,
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int fcoe_rx ( struct io_buffer *iobuf,
|
static int fcoe_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
struct net_device *netdev,
|
const void *ll_dest __unused, const void *ll_source ) {
|
||||||
const void *ll_source ) {
|
|
||||||
struct fcoe_header *fcoehdr;
|
struct fcoe_header *fcoehdr;
|
||||||
struct fcoe_footer *fcoeftr;
|
struct fcoe_footer *fcoeftr;
|
||||||
struct fcoe_port *fcoe;
|
struct fcoe_port *fcoe;
|
||||||
|
|
|
@ -355,7 +355,8 @@ static int ipv4_tx ( struct io_buffer *iobuf,
|
||||||
ntohs ( iphdr->ident ), ntohs ( iphdr->chksum ) );
|
ntohs ( iphdr->ident ), ntohs ( iphdr->chksum ) );
|
||||||
|
|
||||||
/* Hand off to link layer */
|
/* Hand off to link layer */
|
||||||
if ( ( rc = net_tx ( iobuf, netdev, &ipv4_protocol, ll_dest ) ) != 0 ) {
|
if ( ( rc = net_tx ( iobuf, netdev, &ipv4_protocol, ll_dest,
|
||||||
|
netdev->ll_addr ) ) != 0 ) {
|
||||||
DBG ( "IPv4 could not transmit packet via %s: %s\n",
|
DBG ( "IPv4 could not transmit packet via %s: %s\n",
|
||||||
netdev->name, strerror ( rc ) );
|
netdev->name, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -373,12 +374,15 @@ static int ipv4_tx ( struct io_buffer *iobuf,
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer destination source
|
* @v ll_source Link-layer destination source
|
||||||
*
|
*
|
||||||
* This function expects an IP4 network datagram. It processes the headers
|
* This function expects an IP4 network datagram. It processes the headers
|
||||||
* and sends it to the transport layer.
|
* and sends it to the transport layer.
|
||||||
*/
|
*/
|
||||||
static int ipv4_rx ( struct io_buffer *iobuf, struct net_device *netdev __unused,
|
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 ) {
|
||||||
struct iphdr *iphdr = iobuf->data;
|
struct iphdr *iphdr = iobuf->data;
|
||||||
size_t hdrlen;
|
size_t hdrlen;
|
||||||
|
|
|
@ -242,7 +242,8 @@ static int ipv6_tx ( struct io_buffer *iobuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transmit packet */
|
/* Transmit packet */
|
||||||
return net_tx ( iobuf, netdev, &ipv6_protocol, ll_dest );
|
return net_tx ( iobuf, netdev, &ipv6_protocol, ll_dest,
|
||||||
|
netdev->ll_addr );
|
||||||
|
|
||||||
err:
|
err:
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
|
@ -285,12 +286,14 @@ static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
*
|
*
|
||||||
* This function processes a IPv6 packet
|
* This function processes a IPv6 packet
|
||||||
*/
|
*/
|
||||||
static int ipv6_rx ( struct io_buffer *iobuf,
|
static int ipv6_rx ( struct io_buffer *iobuf,
|
||||||
__unused struct net_device *netdev,
|
__unused struct net_device *netdev,
|
||||||
|
__unused const void *ll_dest,
|
||||||
__unused const void *ll_source ) {
|
__unused const void *ll_source ) {
|
||||||
|
|
||||||
struct ip6_header *ip6hdr = iobuf->data;
|
struct ip6_header *ip6hdr = iobuf->data;
|
||||||
|
|
|
@ -607,6 +607,7 @@ struct net_device * last_opened_netdev ( void ) {
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
* @v net_protocol Network-layer protocol
|
* @v net_protocol Network-layer protocol
|
||||||
* @v ll_dest Destination link-layer address
|
* @v ll_dest Destination link-layer address
|
||||||
|
* @v ll_source Source link-layer address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*
|
*
|
||||||
* Prepends link-layer headers to the I/O buffer and transmits the
|
* Prepends link-layer headers to the I/O buffer and transmits the
|
||||||
|
@ -614,7 +615,8 @@ struct net_device * last_opened_netdev ( void ) {
|
||||||
* ownership of the I/O buffer.
|
* ownership of the I/O buffer.
|
||||||
*/
|
*/
|
||||||
int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
struct net_protocol *net_protocol, const void *ll_dest ) {
|
struct net_protocol *net_protocol, const void *ll_dest,
|
||||||
|
const void *ll_source ) {
|
||||||
struct ll_protocol *ll_protocol = netdev->ll_protocol;
|
struct ll_protocol *ll_protocol = netdev->ll_protocol;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -626,7 +628,7 @@ int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
netdev_poll ( netdev );
|
netdev_poll ( netdev );
|
||||||
|
|
||||||
/* Add link-layer header */
|
/* Add link-layer header */
|
||||||
if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, netdev->ll_addr,
|
if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, ll_source,
|
||||||
net_protocol->net_proto ) ) != 0 ) {
|
net_protocol->net_proto ) ) != 0 ) {
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -642,17 +644,19 @@ int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
* @v net_proto Network-layer protocol, in network-byte order
|
* @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 ll_source Source link-layer address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||||
uint16_t net_proto, const void *ll_source ) {
|
uint16_t net_proto, const void *ll_dest, const void *ll_source ) {
|
||||||
struct net_protocol *net_protocol;
|
struct net_protocol *net_protocol;
|
||||||
|
|
||||||
/* Hand off to network-layer protocol, if any */
|
/* Hand off to network-layer protocol, if any */
|
||||||
for_each_table_entry ( net_protocol, NET_PROTOCOLS ) {
|
for_each_table_entry ( net_protocol, NET_PROTOCOLS ) {
|
||||||
if ( net_protocol->net_proto == net_proto )
|
if ( net_protocol->net_proto == net_proto )
|
||||||
return net_protocol->rx ( iobuf, netdev, ll_source );
|
return net_protocol->rx ( iobuf, netdev, ll_dest,
|
||||||
|
ll_source );
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGC ( netdev, "NETDEV %p unknown network protocol %04x\n",
|
DBGC ( netdev, "NETDEV %p unknown network protocol %04x\n",
|
||||||
|
@ -707,7 +711,8 @@ static void net_step ( struct process *process __unused ) {
|
||||||
|
|
||||||
/* Hand packet to network layer */
|
/* Hand packet to network layer */
|
||||||
if ( ( rc = net_rx ( iob_disown ( iobuf ), netdev,
|
if ( ( rc = net_rx ( iob_disown ( iobuf ), netdev,
|
||||||
net_proto, ll_source ) ) != 0 ) {
|
net_proto, ll_dest,
|
||||||
|
ll_source ) ) != 0 ) {
|
||||||
/* Record error for diagnosis */
|
/* Record error for diagnosis */
|
||||||
netdev_rx_err ( netdev, NULL, rc );
|
netdev_rx_err ( netdev, NULL, rc );
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*
|
*
|
||||||
|
@ -43,6 +44,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
*/
|
*/
|
||||||
static int rarp_rx ( struct io_buffer *iobuf,
|
static int rarp_rx ( struct io_buffer *iobuf,
|
||||||
struct net_device *netdev __unused,
|
struct net_device *netdev __unused,
|
||||||
|
const void *ll_dest __unused,
|
||||||
const void *ll_source __unused ) {
|
const void *ll_source __unused ) {
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -45,11 +45,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
*
|
*
|
||||||
* @v iobuf I/O buffer
|
* @v iobuf I/O buffer
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v ll_dest Link-layer destination address
|
||||||
* @v ll_source Link-layer source address
|
* @v ll_source Link-layer source address
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int lotest_rx ( struct io_buffer *iobuf,
|
static int lotest_rx ( struct io_buffer *iobuf,
|
||||||
struct net_device *netdev __unused,
|
struct net_device *netdev __unused,
|
||||||
|
const void *ll_dest __unused,
|
||||||
const void *ll_source __unused ) {
|
const void *ll_source __unused ) {
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
@ -138,8 +140,8 @@ int loopback_test ( struct net_device *sender, struct net_device *receiver,
|
||||||
|
|
||||||
/* Transmit packet */
|
/* Transmit packet */
|
||||||
if ( ( rc = net_tx ( iob_disown ( iobuf ), sender,
|
if ( ( rc = net_tx ( iob_disown ( iobuf ), sender,
|
||||||
&lotest_protocol,
|
&lotest_protocol, receiver->ll_addr,
|
||||||
receiver->ll_addr ) ) != 0 ) {
|
sender->ll_addr ) ) != 0 ) {
|
||||||
printf ( "\nFailed to transmit packet: %s",
|
printf ( "\nFailed to transmit packet: %s",
|
||||||
strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Reference in New Issue