|
iPXE
|
Neighbour discovery. More...
#include <stdint.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <ipxe/iobuf.h>#include <ipxe/retry.h>#include <ipxe/timer.h>#include <ipxe/malloc.h>#include <ipxe/neighbour.h>#include <config/fault.h>Go to the source code of this file.
Macros | |
| #define | NEIGHBOUR_MIN_TIMEOUT ( TICKS_PER_SEC / 8 ) |
| Neighbour discovery minimum timeout. More... | |
| #define | NEIGHBOUR_MAX_TIMEOUT ( TICKS_PER_SEC * 3 ) |
| Neighbour discovery maximum timeout. More... | |
| #define | NEIGHBOUR_DELAY_MAX_BURST 2 |
| Neighbour discovery maximum burst count for delayed transmissions. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| static void | neighbour_expired (struct retry_timer *timer, int fail) |
| Handle neighbour timer expiry. More... | |
| static void | neighbour_free (struct refcnt *refcnt) |
| Free neighbour cache entry. More... | |
| static struct neighbour * | neighbour_create (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest) |
| Create neighbour cache entry. More... | |
| static struct neighbour * | neighbour_find (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest) |
| Find neighbour cache entry. More... | |
| static void | neighbour_discover (struct neighbour *neighbour, struct neighbour_discovery *discovery, const void *net_source) |
| Start neighbour discovery. More... | |
| static void | neighbour_tx_queue (struct neighbour *neighbour) |
| Transmit deferred packets. More... | |
| static void | neighbour_discovered (struct neighbour *neighbour, const void *ll_dest) |
| Complete neighbour discovery. More... | |
| static void | neighbour_destroy (struct neighbour *neighbour, int rc) |
| Destroy neighbour cache entry. More... | |
| int | neighbour_tx (struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, struct neighbour_discovery *discovery, const void *net_source) |
| Transmit packet, determining link-layer address via neighbour discovery. More... | |
| int | neighbour_update (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *ll_dest) |
| Update existing neighbour cache entry. More... | |
| int | neighbour_define (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *ll_dest) |
| Define neighbour cache entry. More... | |
| static void | neighbour_flush (struct net_device *netdev, void *priv __unused) |
| Update neighbour cache on network device state change or removal. More... | |
| static unsigned int | neighbour_discard (void) |
| Discard some cached neighbour entries. More... | |
| struct cache_discarder neighbour_discarder | __cache_discarder (CACHE_EXPENSIVE) |
| Neighbour cache discarder. More... | |
Variables | |
| struct list_head | neighbours = LIST_HEAD_INIT ( neighbours ) |
| The neighbour cache. More... | |
| struct net_driver neighbour_net_driver | __net_driver |
| Neighbour driver (for net device notifications) More... | |
Neighbour discovery.
This file implements the abstract functions of neighbour discovery, independent of the underlying network protocol (e.g. ARP or NDP).
Definition in file neighbour.c.
| #define NEIGHBOUR_MIN_TIMEOUT ( TICKS_PER_SEC / 8 ) |
Neighbour discovery minimum timeout.
Definition at line 47 of file neighbour.c.
| #define NEIGHBOUR_MAX_TIMEOUT ( TICKS_PER_SEC * 3 ) |
Neighbour discovery maximum timeout.
Definition at line 50 of file neighbour.c.
| #define NEIGHBOUR_DELAY_MAX_BURST 2 |
Neighbour discovery maximum burst count for delayed transmissions.
When using delay injection, timer quantisation can cause a large number of delayed packets to be scheduled at the same time. This can quickly exhaust available transmit descriptors, leading to packets that are dropped completely (not just delayed).
Limit the number of delayed packets that we will attempt to transmit at once, to allow time for transmit completions to occur.
Definition at line 62 of file neighbour.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Handle neighbour timer expiry.
| timer | Retry timer |
| fail | Failure indicator |
Definition at line 316 of file neighbour.c.
References container_of, DBGC, neighbour::discovery, ETIMEDOUT, neighbour_discovery::name, net_protocol::name, net_device::name, NEIGHBOUR_DELAY_MS, neighbour_destroy(), neighbour_tx_queue(), neighbour::net_dest, neighbour::net_protocol, neighbour::net_source, neighbour::netdev, netdev, net_protocol::ntoa, rc, start_timer(), strerror(), neighbour::timer, and neighbour_discovery::tx_request.
Referenced by neighbour_create().
|
static |
Free neighbour cache entry.
| refcnt | Reference count |
Definition at line 74 of file neighbour.c.
References assert(), container_of, free, list_empty, neighbour::netdev, netdev_put(), and neighbour::tx_queue.
Referenced by neighbour_create().
|
static |
Create neighbour cache entry.
| netdev | Network device |
| net_protocol | Network-layer protocol |
| net_dest | Destination network-layer address |
| neighbour | Neighbour cache entry, or NULL if allocation failed |
Definition at line 96 of file neighbour.c.
References DBGC, INIT_LIST_HEAD, neighbour::list, list_add, memcpy(), net_protocol::name, net_device::name, neighbour_expired(), neighbour_free(), NEIGHBOUR_MAX_TIMEOUT, NEIGHBOUR_MIN_TIMEOUT, neighbours, net_protocol::net_addr_len, neighbour::net_dest, neighbour::net_protocol, neighbour::netdev, netdev, netdev_get(), net_protocol::ntoa, NULL, ref_init, neighbour::refcnt, neighbour::timer, neighbour::tx_queue, and zalloc().
Referenced by neighbour_define(), and neighbour_tx().
|
static |
Find neighbour cache entry.
| netdev | Network device |
| net_protocol | Network-layer protocol |
| net_dest | Destination network-layer address |
| neighbour | Neighbour cache entry, or NULL if not found |
Definition at line 131 of file neighbour.c.
References neighbour::list, list_add, list_del, list_for_each_entry, memcmp(), neighbours, net_protocol::net_addr_len, neighbour::net_dest, neighbour::net_protocol, neighbour::netdev, netdev, and NULL.
Referenced by neighbour_define(), neighbour_tx(), and neighbour_update().
|
static |
Start neighbour discovery.
| neighbour | Neighbour cache entry |
| discovery | Neighbour discovery protocol |
| net_source | Source network-layer address |
Definition at line 159 of file neighbour.c.
References DBGC, neighbour::discovery, memcpy(), neighbour_discovery::name, net_protocol::name, net_device::name, net_protocol::net_addr_len, neighbour::net_dest, neighbour::net_protocol, neighbour::net_source, neighbour::netdev, netdev, net_protocol::ntoa, start_timer_nodelay(), and neighbour::timer.
Referenced by neighbour_tx().
|
static |
Transmit deferred packets.
| neighbour | Neighbour cache entry |
Definition at line 184 of file neighbour.c.
References count, currticks(), io_buffer::data, DBGC, DBGC2, delay, iob_pull, io_buffer::list, list_del, list_first_entry, net_device::ll_addr, neighbour::ll_dest, net_protocol::name, net_device::name, NEIGHBOUR_DELAY_MAX_BURST, NEIGHBOUR_DELAY_MS, neighbour::net_dest, neighbour::net_protocol, net_tx(), neighbour::netdev, netdev, net_protocol::ntoa, NULL, rc, ref_get, ref_put, neighbour::refcnt, start_timer_fixed(), start_timer_nodelay(), stop_timer(), strerror(), TICKS_PER_MS, neighbour::timer, and neighbour::tx_queue.
Referenced by neighbour_discovered(), neighbour_expired(), and neighbour_tx().
|
static |
Complete neighbour discovery.
| neighbour | Neighbour cache entry |
| ll_dest | Destination link-layer address |
Definition at line 255 of file neighbour.c.
References DBGC, neighbour::discovery, ll_protocol::ll_addr_len, neighbour::ll_dest, net_device::ll_protocol, memcpy(), net_protocol::name, ll_protocol::name, net_device::name, neighbour_tx_queue(), neighbour::net_dest, neighbour::net_protocol, neighbour::netdev, netdev, net_protocol::ntoa, ll_protocol::ntoa, and NULL.
Referenced by neighbour_define(), and neighbour_update().
|
static |
Destroy neighbour cache entry.
| neighbour | Neighbour cache entry |
| rc | Reason for destruction |
Definition at line 280 of file neighbour.c.
References DBGC, DBGC2, neighbour::list, io_buffer::list, list_del, list_first_entry, net_protocol::name, net_device::name, neighbour::net_dest, neighbour::net_protocol, neighbour::netdev, netdev, netdev_tx_err(), net_protocol::ntoa, NULL, rc, ref_put, neighbour::refcnt, stop_timer(), strerror(), neighbour::timer, and neighbour::tx_queue.
Referenced by neighbour_discard(), neighbour_expired(), and neighbour_flush().
| int neighbour_tx | ( | struct io_buffer * | iobuf, |
| struct net_device * | netdev, | ||
| struct net_protocol * | net_protocol, | ||
| const void * | net_dest, | ||
| struct neighbour_discovery * | discovery, | ||
| const void * | net_source | ||
| ) |
Transmit packet, determining link-layer address via neighbour discovery.
| iobuf | I/O buffer |
| netdev | Network device |
| discovery | Neighbour discovery protocol |
| net_protocol | Network-layer protocol |
| net_dest | Destination network-layer address |
| net_source | Source network-layer address |
| rc | Return status code |
Definition at line 367 of file neighbour.c.
References currticks(), DBGC2, delay, neighbour::discovery, ENOMEM, iob_push, io_buffer::list, list_add_tail, net_device::ll_addr, neighbour::ll_dest, net_protocol::name, net_device::name, neighbour_create(), NEIGHBOUR_DELAY_MS, neighbour_discover(), neighbour_find(), neighbour_tx_queue(), net_tx(), netdev, net_protocol::ntoa, rc, and neighbour::tx_queue.
| int neighbour_update | ( | struct net_device * | netdev, |
| struct net_protocol * | net_protocol, | ||
| const void * | net_dest, | ||
| const void * | ll_dest | ||
| ) |
Update existing neighbour cache entry.
| netdev | Network device |
| net_protocol | Network-layer protocol |
| net_dest | Destination network-layer address |
| ll_dest | Destination link-layer address |
| rc | Return status code |
Definition at line 428 of file neighbour.c.
References ENOENT, neighbour::ll_dest, neighbour_discovered(), neighbour_find(), neighbour::net_dest, and netdev.
Referenced by arp_rx(), and ndp_rx_neighbour_advertisement_ll_target().
| int neighbour_define | ( | struct net_device * | netdev, |
| struct net_protocol * | net_protocol, | ||
| const void * | net_dest, | ||
| const void * | ll_dest | ||
| ) |
Define neighbour cache entry.
| netdev | Network device |
| net_protocol | Network-layer protocol |
| net_dest | Destination network-layer address |
| ll_dest | Destination link-layer address, if known |
| rc | Return status code |
Definition at line 453 of file neighbour.c.
References ENOMEM, neighbour::ll_dest, neighbour_create(), neighbour_discovered(), neighbour_find(), neighbour::net_dest, and netdev.
Referenced by ndp_rx_neighbour_solicitation_ll_source(), and ndp_rx_router_advertisement_ll_source().
|
static |
Update neighbour cache on network device state change or removal.
| netdev | Network device |
| priv | Private data |
Definition at line 478 of file neighbour.c.
References ENODEV, neighbour::list, list_for_each_entry_safe, neighbour_destroy(), neighbours, netdev, netdev_is_open(), and tmp.
|
static |
Discard some cached neighbour entries.
| discarded | Number of cached items discarded |
Definition at line 501 of file neighbour.c.
References ENOBUFS, neighbour::list, list_last_entry, neighbour_destroy(), and neighbours.
| struct cache_discarder neighbour_discarder __cache_discarder | ( | CACHE_EXPENSIVE | ) |
Neighbour cache discarder.
Neighbour cache entries are deemed to have a high replacement cost, since flushing an active neighbour cache entry midway through a TCP transfer will cause substantial disruption.
| struct list_head neighbours = LIST_HEAD_INIT ( neighbours ) |
The neighbour cache.
Definition at line 65 of file neighbour.c.
Referenced by neighbour_create(), neighbour_discard(), neighbour_find(), neighbour_flush(), and nstat().
| struct net_driver neighbour_net_driver __net_driver |
Neighbour driver (for net device notifications)
Definition at line 490 of file neighbour.c.
1.8.15