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>
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... | |
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_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, const void *ll_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) |
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 46 of file neighbour.c.
#define NEIGHBOUR_MAX_TIMEOUT ( TICKS_PER_SEC * 3 ) |
Neighbour discovery maximum timeout.
Definition at line 49 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 255 of file neighbour.c.
References container_of, DBGC, neighbour::discovery, ETIMEDOUT, neighbour_discovery::name, net_protocol::name, net_device::name, neighbour_destroy(), 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 61 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 83 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 118 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 146 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 |
Complete neighbour discovery.
neighbour | Neighbour cache entry |
ll_dest | Destination link-layer address |
Definition at line 172 of file neighbour.c.
References DBGC, DBGC2, io_buffer::list, list_del, list_first_entry, net_device::ll_addr, ll_protocol::ll_addr_len, neighbour::ll_dest, net_device::ll_protocol, memcpy(), net_protocol::name, ll_protocol::name, net_device::name, neighbour::net_dest, neighbour::net_protocol, net_tx(), neighbour::netdev, netdev, net_protocol::ntoa, ll_protocol::ntoa, NULL, rc, ref_get, ref_put, neighbour::refcnt, stop_timer(), strerror(), neighbour::timer, and neighbour::tx_queue.
Referenced by neighbour_define(), and neighbour_update().
|
static |
Destroy neighbour cache entry.
neighbour | Neighbour cache entry |
rc | Reason for destruction |
Definition at line 219 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, | ||
const void * | ll_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 |
ll_source | Source link-layer address |
rc | Return status code |
Definition at line 299 of file neighbour.c.
References DBGC2, neighbour::discovery, ENOMEM, io_buffer::list, list_add_tail, neighbour::ll_dest, net_protocol::name, net_device::name, neighbour_create(), neighbour_discover(), neighbour_find(), neighbour_has_ll_dest(), neighbour::net_dest, neighbour::net_source, net_tx(), netdev, net_protocol::ntoa, 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 338 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 363 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 |
Definition at line 387 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 410 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 52 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 399 of file neighbour.c.