mirror of
https://github.com/ipxe/ipxe
synced 2025-12-15 09:04:37 +03:00
Clarified packet ownership transfer between a few functions.
Added a large number of missing calls to free_pkb(). In the case of UDP, no received packets were ever freed, which lead to memory exhaustion remarkably quickly once pxelinux started up. In general, any function with _rx() in its name which accepts a pk_buff *must* either call free_pkb() or pass the pkb to another _rx() function (e.g. the next layer up the stack). Since the UDP (and TCP) layers don't pass packet buffers up to the higher-layer protocols (the "applications"), they must free the packet buffer after calling the application's newdata() method.
This commit is contained in:
@@ -97,8 +97,9 @@ int net_tx ( struct pk_buff *pkb, struct net_device *netdev,
|
||||
* @v netdev Network device
|
||||
* @v net_proto Network-layer protocol, in network-byte order
|
||||
* @v ll_source Source link-layer address
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
void net_rx ( struct pk_buff *pkb, struct net_device *netdev,
|
||||
int net_rx ( struct pk_buff *pkb, struct net_device *netdev,
|
||||
uint16_t net_proto, const void *ll_source ) {
|
||||
struct net_protocol *net_protocol;
|
||||
|
||||
@@ -106,10 +107,11 @@ void net_rx ( struct pk_buff *pkb, struct net_device *netdev,
|
||||
for ( net_protocol = net_protocols ; net_protocol < net_protocols_end ;
|
||||
net_protocol++ ) {
|
||||
if ( net_protocol->net_proto == net_proto ) {
|
||||
net_protocol->rx ( pkb, netdev, ll_source );
|
||||
break;
|
||||
return net_protocol->rx ( pkb, netdev, ll_source );
|
||||
}
|
||||
}
|
||||
free_pkb ( pkb );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user