From bac97eb979e5048b065f01c6b5e7d63ffc3abf48 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Apr 2006 17:17:43 +0000 Subject: Change semantics of network API so that packet-absorbing calls *always* take ownership of the packet, rather than doing so only if they return success. This breaks semantic compatibility with Linux's hard_start_xmit() method, but means that we don't have to worry so much about error cases. Split mechanism of processing received packets (net_rx_process()) out from policy (net_step()), preparatory to putting net_step() in a separate object. --- src/net/arp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/net/arp.c') diff --git a/src/net/arp.c b/src/net/arp.c index 3720acfc4..af7d6e122 100644 --- a/src/net/arp.c +++ b/src/net/arp.c @@ -154,10 +154,8 @@ int arp_resolve ( struct net_device *netdev, const struct net_header *nethdr, nethdr->dest_net_addr, net_protocol->net_addr_len ); /* Transmit ARP request */ - if ( ( rc = net_transmit_via ( pkb, netdev ) ) != 0 ) { - free_pkb ( pkb ); + if ( ( rc = net_transmit_via ( pkb, netdev ) ) != 0 ) return rc; - } return -ENOENT; } @@ -230,7 +228,7 @@ static int arp_rx ( struct pk_buff *pkb ) { if ( arphdr->ar_op != htons ( ARPOP_REQUEST ) ) goto done; - /* Change request to a reply, and send it */ + /* Change request to a reply */ DBG ( "ARP reply: %s %s => %s %s\n", net_protocol->name, net_protocol->ntoa ( arp_target_pa ( arphdr ) ), ll_protocol->name, ll_protocol->ntoa ( netdev->ll_addr ) ); @@ -238,8 +236,10 @@ static int arp_rx ( struct pk_buff *pkb ) { memswap ( arp_sender_ha ( arphdr ), arp_target_ha ( arphdr ), arphdr->ar_hln + arphdr->ar_pln ); memcpy ( arp_target_ha ( arphdr ), netdev->ll_addr, arphdr->ar_hln ); - if ( net_transmit_via ( pkb, netdev ) == 0 ) - pkb = NULL; + + /* Send reply */ + net_transmit_via ( pkb, netdev ); + pkb = NULL; done: free_pkb ( pkb ); @@ -286,7 +286,7 @@ arp_ntoa ( const void *net_addr __attribute__ (( unused )) ) { struct net_protocol arp_protocol = { .name = "ARP", .net_proto = htons ( ETH_P_ARP ), - .rx = arp_rx, + .rx_process = arp_rx, .route = arp_route, .ntoa = arp_ntoa, }; -- cgit v1.2.3-55-g7522