net/ip: Removing useless extra data capability in neighbors
This is not used by anyone, and is unlikely to be useful actually. Helps to save 4 bytes for each instance of struct net_nbr also (removing a 2 bytes attributes, which was anyway generating a 4bytes loss due to structure misalignment). Removing relevant useless functions related to it as well. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
a3d7278588
commit
a4af2ac8dc
|
@ -80,7 +80,7 @@ static void ipv6_nd_restart_reachable_timer(struct net_nbr *nbr, int64_t time);
|
|||
#define DELAY_FIRST_PROBE_TIME (5 * MSEC_PER_SEC)
|
||||
#define RETRANS_TIMER 1000 /* ms */
|
||||
|
||||
extern void net_neighbor_data_remove(struct net_nbr *nbr);
|
||||
extern void net_neighbor_remove(struct net_nbr *nbr);
|
||||
extern void net_neighbor_table_clear(struct net_nbr_table *table);
|
||||
|
||||
/** Neighbor Solicitation reply timer */
|
||||
|
@ -89,8 +89,7 @@ static struct k_work_delayable ipv6_ns_reply_timer;
|
|||
NET_NBR_POOL_INIT(net_neighbor_pool,
|
||||
CONFIG_NET_IPV6_MAX_NEIGHBORS,
|
||||
sizeof(struct net_ipv6_nbr_data),
|
||||
net_neighbor_data_remove,
|
||||
0);
|
||||
net_neighbor_remove);
|
||||
|
||||
NET_NBR_TABLE_INIT(NET_NBR_GLOBAL,
|
||||
neighbor,
|
||||
|
@ -665,7 +664,7 @@ out:
|
|||
return nbr;
|
||||
}
|
||||
|
||||
void net_neighbor_data_remove(struct net_nbr *nbr)
|
||||
void net_neighbor_remove(struct net_nbr *nbr)
|
||||
{
|
||||
NET_DBG("Neighbor %p removed", nbr);
|
||||
|
||||
|
|
|
@ -62,8 +62,7 @@ static inline struct net_nbr *get_nbr(struct net_nbr *start, int idx)
|
|||
NET_ASSERT(idx < CONFIG_NET_IPV6_MAX_NEIGHBORS);
|
||||
|
||||
return (struct net_nbr *)((uint8_t *)start +
|
||||
((sizeof(struct net_nbr) +
|
||||
start->size + start->extra_data_size) * idx));
|
||||
((sizeof(struct net_nbr) + start->size) * idx));
|
||||
}
|
||||
|
||||
struct net_nbr *net_nbr_get(struct net_nbr_table *table)
|
||||
|
|
|
@ -56,9 +56,6 @@ struct net_nbr {
|
|||
/** Amount of data that this neighbor buffer can store. */
|
||||
const uint16_t size;
|
||||
|
||||
/** Extra data size associated with this neighbor */
|
||||
const uint16_t extra_data_size;
|
||||
|
||||
/** Interface this neighbor is found */
|
||||
struct net_if *iface;
|
||||
|
||||
|
@ -75,17 +72,15 @@ struct net_nbr {
|
|||
};
|
||||
|
||||
/* This is an array of struct net_nbr + some additional data */
|
||||
#define NET_NBR_POOL_INIT(_name, _count, _size, _remove, _extra_size) \
|
||||
#define NET_NBR_POOL_INIT(_name, _count, _size, _remove) \
|
||||
struct { \
|
||||
struct net_nbr nbr; \
|
||||
uint8_t data[ROUND_UP(_size, 4)] __net_nbr_align; \
|
||||
uint8_t extra[ROUND_UP(_extra_size, 4)] __net_nbr_align;\
|
||||
} _name[_count] = { \
|
||||
[0 ... (_count - 1)] = { .nbr = { \
|
||||
.idx = NET_NBR_LLADDR_UNKNOWN, \
|
||||
.remove = _remove, \
|
||||
.size = ROUND_UP(_size, 4), \
|
||||
.extra_data_size = ROUND_UP(_extra_size, 4) } },\
|
||||
.size = ROUND_UP(_size, 4) } }, \
|
||||
}
|
||||
|
||||
struct net_nbr_table {
|
||||
|
@ -115,18 +110,6 @@ struct net_nbr_table {
|
|||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the extra data of a neighbor entry.
|
||||
*
|
||||
* @param nbr A valid pointer to neighbor
|
||||
*
|
||||
* @return Pointer to the extra data of the nbr.
|
||||
*/
|
||||
static inline void *net_nbr_extra_data(struct net_nbr *nbr)
|
||||
{
|
||||
return (void *)ROUND_UP((nbr->__nbr + nbr->size), sizeof(int));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement the reference count. If count goes to 0, the neighbor
|
||||
* is released and returned to free list.
|
||||
|
|
|
@ -29,10 +29,6 @@ LOG_MODULE_REGISTER(net_route, CONFIG_NET_ROUTE_LOG_LEVEL);
|
|||
#include "nbr.h"
|
||||
#include "route.h"
|
||||
|
||||
#if !defined(NET_ROUTE_EXTRA_DATA_SIZE)
|
||||
#define NET_ROUTE_EXTRA_DATA_SIZE 0
|
||||
#endif
|
||||
|
||||
/* We keep track of the routes in a separate list so that we can remove
|
||||
* the oldest routes (at tail) if needed.
|
||||
*/
|
||||
|
@ -55,8 +51,7 @@ static void net_route_nexthop_remove(struct net_nbr *nbr)
|
|||
NET_NBR_POOL_INIT(net_route_nexthop_pool,
|
||||
CONFIG_NET_MAX_NEXTHOPS,
|
||||
sizeof(struct net_route_nexthop),
|
||||
net_route_nexthop_remove,
|
||||
0);
|
||||
net_route_nexthop_remove);
|
||||
|
||||
static inline struct net_route_nexthop *net_nexthop_data(struct net_nbr *nbr)
|
||||
{
|
||||
|
@ -115,8 +110,7 @@ static void net_route_entries_table_clear(struct net_nbr_table *table)
|
|||
NET_NBR_POOL_INIT(net_route_entries_pool,
|
||||
CONFIG_NET_MAX_ROUTES,
|
||||
sizeof(struct net_route_entry),
|
||||
net_route_entry_remove,
|
||||
NET_ROUTE_EXTRA_DATA_SIZE);
|
||||
net_route_entry_remove);
|
||||
|
||||
NET_NBR_TABLE_INIT(NET_NBR_LOCAL, nbr_routes, net_route_entries_pool,
|
||||
net_route_entries_table_clear);
|
||||
|
@ -665,70 +659,6 @@ int net_route_del_by_nexthop(struct net_if *iface, struct in6_addr *nexthop)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int net_route_del_by_nexthop_data(struct net_if *iface,
|
||||
struct in6_addr *nexthop,
|
||||
void *data)
|
||||
{
|
||||
int count = 0, status = 0;
|
||||
struct net_nbr *nbr_nexthop;
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
int i, ret;
|
||||
|
||||
NET_ASSERT(iface);
|
||||
NET_ASSERT(nexthop);
|
||||
|
||||
net_ipv6_nbr_lock();
|
||||
|
||||
nbr_nexthop = net_ipv6_nbr_lookup(iface, nexthop);
|
||||
if (!nbr_nexthop) {
|
||||
net_ipv6_nbr_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < CONFIG_NET_MAX_ROUTES; i++) {
|
||||
struct net_nbr *nbr = get_nbr(i);
|
||||
struct net_route_entry *route = net_route_data(nbr);
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route,
|
||||
node) {
|
||||
void *extra_data;
|
||||
|
||||
if (nexthop_route->nbr != nbr_nexthop) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nbr->extra_data_size == 0U) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Routing engine specific extra data needs
|
||||
* to match too.
|
||||
*/
|
||||
extra_data = net_nbr_extra_data(nbr_nexthop);
|
||||
if (extra_data != data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = net_route_del(route);
|
||||
if (!ret) {
|
||||
count++;
|
||||
} else {
|
||||
status = ret;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
net_ipv6_nbr_unlock();
|
||||
|
||||
if (count) {
|
||||
return count;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
struct in6_addr *net_route_get_nexthop(struct net_route_entry *route)
|
||||
{
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
|
|
|
@ -138,22 +138,6 @@ int net_route_del(struct net_route_entry *entry);
|
|||
int net_route_del_by_nexthop(struct net_if *iface,
|
||||
struct in6_addr *nexthop);
|
||||
|
||||
/**
|
||||
* @brief Delete a route from routing table by nexthop if the routing engine
|
||||
* specific data matches.
|
||||
*
|
||||
* @detail The routing engine specific data could be the RPL data.
|
||||
*
|
||||
* @param iface Network interface to use.
|
||||
* @param nexthop IPv6 address of the nexthop device.
|
||||
* @param data Routing engine specific data.
|
||||
*
|
||||
* @return number of routes deleted, <0 if error
|
||||
*/
|
||||
int net_route_del_by_nexthop_data(struct net_if *iface,
|
||||
struct in6_addr *nexthop,
|
||||
void *data);
|
||||
|
||||
/**
|
||||
* @brief Update the route lifetime.
|
||||
*
|
||||
|
|
|
@ -45,7 +45,7 @@ static void net_neighbor_table_clear(struct net_nbr_table *table)
|
|||
}
|
||||
|
||||
NET_NBR_POOL_INIT(net_test_neighbor_pool, CONFIG_NET_IPV6_MAX_NEIGHBORS,
|
||||
0, net_neighbor_data_remove, 0);
|
||||
0, net_neighbor_data_remove);
|
||||
|
||||
NET_NBR_TABLE_INIT(NET_NBR_LOCAL, test_neighbor, net_test_neighbor_pool,
|
||||
net_neighbor_table_clear);
|
||||
|
|
Loading…
Reference in a new issue