13#include <netlink-private/netlink.h>
14#include <netlink-private/utils.h>
15#include <netlink/netlink.h>
16#include <netlink/utils.h>
17#include <netlink/route/rtnl.h>
18#include <netlink/route/neightbl.h>
19#include <netlink/route/link.h>
22#define NEIGHTBL_ATTR_FAMILY 0x001
23#define NEIGHTBL_ATTR_STATS 0x002
24#define NEIGHTBL_ATTR_NAME 0x004
25#define NEIGHTBL_ATTR_THRESH1 0x008
26#define NEIGHTBL_ATTR_THRESH2 0x010
27#define NEIGHTBL_ATTR_THRESH3 0x020
28#define NEIGHTBL_ATTR_CONFIG 0x040
29#define NEIGHTBL_ATTR_PARMS 0x080
30#define NEIGHTBL_ATTR_GC_INTERVAL 0x100
32#define NEIGHTBLPARM_ATTR_IFINDEX 0x0001
33#define NEIGHTBLPARM_ATTR_REFCNT 0x0002
34#define NEIGHTBLPARM_ATTR_QUEUE_LEN 0x0004
35#define NEIGHTBLPARM_ATTR_APP_PROBES 0x0008
36#define NEIGHTBLPARM_ATTR_UCAST_PROBES 0x0010
37#define NEIGHTBLPARM_ATTR_MCAST_PROBES 0x0020
38#define NEIGHTBLPARM_ATTR_PROXY_QLEN 0x0040
39#define NEIGHTBLPARM_ATTR_REACHABLE_TIME 0x0080
40#define NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME 0x0100
41#define NEIGHTBLPARM_ATTR_RETRANS_TIME 0x0200
42#define NEIGHTBLPARM_ATTR_GC_STALETIME 0x0400
43#define NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME 0x0800
44#define NEIGHTBLPARM_ATTR_ANYCAST_DELAY 0x1000
45#define NEIGHTBLPARM_ATTR_PROXY_DELAY 0x2000
46#define NEIGHTBLPARM_ATTR_LOCKTIME 0x4000
48static struct nl_cache_ops rtnl_neightbl_ops;
49static struct nl_object_ops neightbl_obj_ops;
52static uint64_t neightbl_compare(
struct nl_object *_a,
struct nl_object *_b,
53 uint64_t attrs,
int flags)
55 struct rtnl_neightbl *a = (
struct rtnl_neightbl *)_a;
56 struct rtnl_neightbl *b = (
struct rtnl_neightbl *)_b;
59#define NT_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGHTBL_ATTR_##ATTR, a, b, EXPR)
61 diff |= NT_DIFF(FAMILY, a->nt_family != b->nt_family);
62 diff |= NT_DIFF(NAME, strcmp(a->nt_name, b->nt_name));
63 diff |= NT_DIFF(THRESH1, a->nt_gc_thresh1 != b->nt_gc_thresh1);
64 diff |= NT_DIFF(THRESH2, a->nt_gc_thresh2 != b->nt_gc_thresh2);
65 diff |= NT_DIFF(THRESH3, a->nt_gc_thresh3 != b->nt_gc_thresh3);
66 diff |= NT_DIFF(GC_INTERVAL, a->nt_gc_interval != b->nt_gc_interval);
70 if (!(a->ce_mask & NEIGHTBL_ATTR_PARMS) &&
71 !(b->ce_mask & NEIGHTBL_ATTR_PARMS))
77#define REQ(F) (fp->ntp_mask & NEIGHTBLPARM_ATTR_##F)
78#define AVAIL(F) (op->ntp_mask & NEIGHTBLPARM_ATTR_##F)
79#define _C(F, N) (REQ(F) && (!AVAIL(F) || (op->N != fp->N)))
80 if (_C(IFINDEX, ntp_ifindex) ||
81 _C(QUEUE_LEN, ntp_queue_len) ||
82 _C(APP_PROBES, ntp_app_probes) ||
83 _C(UCAST_PROBES, ntp_ucast_probes) ||
84 _C(MCAST_PROBES, ntp_mcast_probes) ||
85 _C(PROXY_QLEN, ntp_proxy_qlen) ||
86 _C(LOCKTIME, ntp_locktime) ||
87 _C(RETRANS_TIME, ntp_retrans_time) ||
88 _C(BASE_REACHABLE_TIME, ntp_base_reachable_time) ||
89 _C(GC_STALETIME, ntp_gc_stale_time) ||
90 _C(DELAY_PROBE_TIME, ntp_probe_delay) ||
91 _C(ANYCAST_DELAY, ntp_anycast_delay) ||
92 _C(PROXY_DELAY, ntp_proxy_delay))
102static struct nla_policy neightbl_policy[NDTA_MAX + 1] = {
104 [NDTA_THRESH1] = { .type =
NLA_U32 },
105 [NDTA_THRESH2] = { .type =
NLA_U32 },
106 [NDTA_THRESH3] = { .type =
NLA_U32 },
107 [NDTA_GC_INTERVAL] = { .type =
NLA_U32 },
108 [NDTA_CONFIG] = { .minlen =
sizeof(
struct ndt_config) },
109 [NDTA_STATS] = { .minlen =
sizeof(
struct ndt_stats) },
113static int neightbl_msg_parser(
struct nl_cache_ops *ops,
114 struct sockaddr_nl *who,
struct nlmsghdr *n,
115 struct nl_parser_param *pp)
117 struct rtnl_neightbl *ntbl;
118 struct nlattr *tb[NDTA_MAX + 1];
119 struct rtgenmsg *rtmsg;
122 ntbl = rtnl_neightbl_alloc();
128 ntbl->ce_msgtype = n->nlmsg_type;
131 err =
nlmsg_parse(n,
sizeof(*rtmsg), tb, NDTA_MAX, neightbl_policy);
135 ntbl->nt_family = rtmsg->rtgen_family;
137 if (tb[NDTA_NAME] == NULL) {
138 err = -NLE_MISSING_ATTR;
142 nla_strlcpy(ntbl->nt_name, tb[NDTA_NAME], NTBLNAMSIZ);
143 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
145 if (tb[NDTA_THRESH1]) {
146 ntbl->nt_gc_thresh1 =
nla_get_u32(tb[NDTA_THRESH1]);
147 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
150 if (tb[NDTA_THRESH2]) {
151 ntbl->nt_gc_thresh2 =
nla_get_u32(tb[NDTA_THRESH2]);
152 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
155 if (tb[NDTA_THRESH3]) {
156 ntbl->nt_gc_thresh3 =
nla_get_u32(tb[NDTA_THRESH3]);
157 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
160 if (tb[NDTA_GC_INTERVAL]) {
161 ntbl->nt_gc_interval =
nla_get_u32(tb[NDTA_GC_INTERVAL]);
162 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
165 if (tb[NDTA_CONFIG]) {
167 sizeof(ntbl->nt_config));
168 ntbl->ce_mask |= NEIGHTBL_ATTR_CONFIG;
171 if (tb[NDTA_STATS]) {
173 sizeof(ntbl->nt_stats));
174 ntbl->ce_mask |= NEIGHTBL_ATTR_STATS;
177 if (tb[NDTA_PARMS]) {
178 struct nlattr *tbp[NDTPA_MAX + 1];
179 struct rtnl_neightbl_parms *p = &ntbl->nt_parms;
185#define COPY_ENTRY(name, var) \
186 if (tbp[NDTPA_##name]) { \
187 p->ntp_##var = nla_get_u32(tbp[NDTPA_##name]); \
188 p->ntp_mask |= NEIGHTBLPARM_ATTR_##name; \
191 COPY_ENTRY(IFINDEX, ifindex);
192 COPY_ENTRY(REFCNT, refcnt);
193 COPY_ENTRY(QUEUE_LEN, queue_len);
194 COPY_ENTRY(APP_PROBES, app_probes);
195 COPY_ENTRY(UCAST_PROBES, ucast_probes);
196 COPY_ENTRY(MCAST_PROBES, mcast_probes);
197 COPY_ENTRY(PROXY_QLEN, proxy_qlen);
198 COPY_ENTRY(PROXY_DELAY, proxy_delay);
199 COPY_ENTRY(ANYCAST_DELAY, anycast_delay);
200 COPY_ENTRY(LOCKTIME, locktime);
201 COPY_ENTRY(REACHABLE_TIME, reachable_time);
202 COPY_ENTRY(BASE_REACHABLE_TIME, base_reachable_time);
203 COPY_ENTRY(RETRANS_TIME, retrans_time);
204 COPY_ENTRY(GC_STALETIME, gc_stale_time);
205 COPY_ENTRY(DELAY_PROBE_TIME, probe_delay);
208 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
211 err = pp->pp_cb((
struct nl_object *)ntbl, pp);
213 rtnl_neightbl_put(ntbl);
217static int neightbl_request_update(
struct nl_cache *c,
struct nl_sock *h)
222static void neightbl_dump_line(
struct nl_object *arg,
struct nl_dump_params *p)
224 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *)arg;
226 nl_dump_line(p,
"%s", ntbl->nt_name);
228 if (ntbl->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX) {
229 struct nl_cache *link_cache;
237 ntbl->nt_parms.ntp_ifindex,
239 nl_cache_put(link_cache);
241 nl_dump(p,
"<%u> ", ntbl->nt_parms.ntp_ifindex);
245 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG)
246 nl_dump(p,
"entries %u ", ntbl->nt_config.ndtc_entries);
248 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
249 char rt[32], rt2[32];
250 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
252 nl_dump(p,
"reachable-time %s retransmit-time %s",
253 nl_msec2str(pa->ntp_reachable_time, rt,
sizeof(rt)),
254 nl_msec2str(pa->ntp_retrans_time, rt2,
sizeof(rt2)));
260static void neightbl_dump_details(
struct nl_object *arg,
263 char x[32], y[32], z[32];
264 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *)arg;
266 neightbl_dump_line(arg, p);
268 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG) {
269 nl_dump_line(p,
" key-len %u entry-size %u last-flush %s\n",
270 ntbl->nt_config.ndtc_key_len,
271 ntbl->nt_config.ndtc_entry_size,
276 " gc threshold %u/%u/%u interval %s "
277 "chain-position %u\n",
278 ntbl->nt_gc_thresh1, ntbl->nt_gc_thresh2,
281 ntbl->nt_config.ndtc_hash_chain_gc);
283 nl_dump_line(p,
" hash-rand 0x%08X/0x%08X last-rand %s\n",
284 ntbl->nt_config.ndtc_hash_rnd,
285 ntbl->nt_config.ndtc_hash_mask,
290 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
291 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
294 " refcnt %u pending-queue-limit %u "
295 "proxy-delayed-queue-limit %u\n",
296 pa->ntp_refcnt, pa->ntp_queue_len,
300 " num-userspace-probes %u num-unicast-probes "
301 "%u num-multicast-probes %u\n",
302 pa->ntp_app_probes, pa->ntp_ucast_probes,
303 pa->ntp_mcast_probes);
306 " min-age %s base-reachable-time %s "
307 "stale-check-interval %s\n",
314 " initial-probe-delay %s answer-delay %s "
315 "proxy-answer-delay %s\n",
322static void neightbl_dump_stats(
struct nl_object *arg,
struct nl_dump_params *p)
324 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *)arg;
326 neightbl_dump_details(arg, p);
328 if (!(ntbl->ce_mask & NEIGHTBL_ATTR_STATS))
333 " lookups %llu hits %llu failed %llu"
334 " allocations %llu destroys %llu\n",
335 (
long long unsigned)ntbl->nt_stats.ndts_lookups,
336 (
long long unsigned)ntbl->nt_stats.ndts_hits,
337 (
long long unsigned)ntbl->nt_stats.ndts_res_failed,
338 (
long long unsigned)ntbl->nt_stats.ndts_allocs,
339 (
long long unsigned)ntbl->nt_stats.ndts_destroys);
343 " hash-grows %llu forced-gc-runs %llu"
344 " periodic-gc-runs %llu\n",
345 (
long long unsigned)ntbl->nt_stats.ndts_hash_grows,
346 (
long long unsigned)ntbl->nt_stats.ndts_forced_gc_runs,
347 (
long long unsigned)ntbl->nt_stats.ndts_periodic_gc_runs);
351 " rcv-unicast-probes %llu"
352 " rcv-multicast-probes %llu"
354 (
long long unsigned)ntbl->nt_stats.ndts_rcv_probes_ucast,
355 (
long long unsigned)ntbl->nt_stats.ndts_rcv_probes_mcast);
363struct rtnl_neightbl *rtnl_neightbl_alloc(
void)
368void rtnl_neightbl_put(
struct rtnl_neightbl *neightbl)
410 const char *name,
int ifindex)
412 struct rtnl_neightbl *nt;
414 if (cache->c_ops != &rtnl_neightbl_ops)
417 nl_list_for_each_entry (nt, &cache->c_items, ce_list) {
418 if (!strcasecmp(nt->nt_name, name) &&
419 ((!ifindex && !nt->nt_parms.ntp_ifindex) ||
420 (ifindex && ifindex == nt->nt_parms.ntp_ifindex))) {
453 struct rtnl_neightbl *tmpl,
454 struct nl_msg **result)
456 struct nl_msg *m, *parms = NULL;
457 struct ndtmsg ndt = {
458 .ndtm_family = old->nt_family,
465 if (
nlmsg_append(m, &ndt,
sizeof(ndt), NLMSG_ALIGNTO) < 0)
466 goto nla_put_failure;
470 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH1)
473 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
476 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
479 if (tmpl->ce_mask & NEIGHTBL_ATTR_GC_INTERVAL)
480 NLA_PUT_U64(m, NDTA_GC_INTERVAL, tmpl->nt_gc_interval);
482 if (tmpl->ce_mask & NEIGHTBL_ATTR_PARMS) {
483 struct rtnl_neightbl_parms *p = &tmpl->nt_parms;
487 goto nla_put_failure;
489 if (old->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX)
491 old->nt_parms.ntp_ifindex);
493 if (p->ntp_mask & NEIGHTBLPARM_ATTR_QUEUE_LEN)
494 NLA_PUT_U32(parms, NDTPA_QUEUE_LEN, p->ntp_queue_len);
496 if (p->ntp_mask & NEIGHTBLPARM_ATTR_APP_PROBES)
497 NLA_PUT_U32(parms, NDTPA_APP_PROBES, p->ntp_app_probes);
499 if (p->ntp_mask & NEIGHTBLPARM_ATTR_UCAST_PROBES)
501 p->ntp_ucast_probes);
503 if (p->ntp_mask & NEIGHTBLPARM_ATTR_MCAST_PROBES)
505 p->ntp_mcast_probes);
507 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_QLEN)
508 NLA_PUT_U32(parms, NDTPA_PROXY_QLEN, p->ntp_proxy_qlen);
510 if (p->ntp_mask & NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME)
512 p->ntp_base_reachable_time);
514 if (p->ntp_mask & NEIGHTBLPARM_ATTR_RETRANS_TIME)
516 p->ntp_retrans_time);
518 if (p->ntp_mask & NEIGHTBLPARM_ATTR_GC_STALETIME)
520 p->ntp_gc_stale_time);
522 if (p->ntp_mask & NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME)
526 if (p->ntp_mask & NEIGHTBLPARM_ATTR_ANYCAST_DELAY)
528 p->ntp_anycast_delay);
530 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_DELAY)
534 if (p->ntp_mask & NEIGHTBLPARM_ATTR_LOCKTIME)
535 NLA_PUT_U64(parms, NDTPA_LOCKTIME, p->ntp_locktime);
538 goto nla_put_failure;
567 struct rtnl_neightbl *tmpl)
580 return wait_for_ack(sk);
590void rtnl_neightbl_set_family(
struct rtnl_neightbl *ntbl,
int family)
592 ntbl->nt_family = family;
593 ntbl->ce_mask |= NEIGHTBL_ATTR_FAMILY;
596void rtnl_neightbl_set_gc_interval(
struct rtnl_neightbl *ntbl, uint64_t ms)
598 ntbl->nt_gc_interval = ms;
599 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
602void rtnl_neightbl_set_gc_tresh1(
struct rtnl_neightbl *ntbl,
int thresh)
604 ntbl->nt_gc_thresh1 = thresh;
605 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
608void rtnl_neightbl_set_gc_tresh2(
struct rtnl_neightbl *ntbl,
int thresh)
610 ntbl->nt_gc_thresh2 = thresh;
611 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
614void rtnl_neightbl_set_gc_tresh3(
struct rtnl_neightbl *ntbl,
int thresh)
616 ntbl->nt_gc_thresh3 = thresh;
617 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
620void rtnl_neightbl_set_name(
struct rtnl_neightbl *ntbl,
const char *name)
622 _nl_strncpy_trunc(ntbl->nt_name, name,
sizeof(ntbl->nt_name));
623 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
626void rtnl_neightbl_set_dev(
struct rtnl_neightbl *ntbl,
int ifindex)
628 ntbl->nt_parms.ntp_ifindex = ifindex;
629 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_IFINDEX;
630 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
640 ntbl->nt_parms.ntp_queue_len = len;
641 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_QUEUE_LEN;
642 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
652 ntbl->nt_parms.ntp_proxy_qlen = len;
653 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_QLEN;
654 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
664 ntbl->nt_parms.ntp_app_probes = probes;
665 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_APP_PROBES;
666 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
676 ntbl->nt_parms.ntp_ucast_probes = probes;
677 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_UCAST_PROBES;
678 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
688 ntbl->nt_parms.ntp_mcast_probes = probes;
689 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_MCAST_PROBES;
690 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
701 ntbl->nt_parms.ntp_base_reachable_time = ms;
702 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME;
703 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
713 ntbl->nt_parms.ntp_retrans_time = ms;
714 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_RETRANS_TIME;
715 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
725 ntbl->nt_parms.ntp_gc_stale_time = ms;
726 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_GC_STALETIME;
727 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
737 ntbl->nt_parms.ntp_probe_delay = ms;
738 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME;
739 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
749 ntbl->nt_parms.ntp_anycast_delay = ms;
750 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_ANYCAST_DELAY;
751 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
761 ntbl->nt_parms.ntp_proxy_delay = ms;
762 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_DELAY;
763 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
773 ntbl->nt_parms.ntp_locktime = ms;
774 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_LOCKTIME;
775 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
780static struct nl_object_ops neightbl_obj_ops = {
781 .oo_name =
"route/neightbl",
782 .oo_size =
sizeof(
struct rtnl_neightbl),
788 .oo_compare = neightbl_compare,
791static struct nl_cache_ops rtnl_neightbl_ops = {
792 .co_name =
"route/neightbl",
793 .co_hdrsize =
sizeof(
struct rtgenmsg),
795 { RTM_NEWNEIGHTBL, NL_ACT_NEW,
"new" },
796 { RTM_SETNEIGHTBL, NL_ACT_SET,
"set" },
797 { RTM_GETNEIGHTBL, NL_ACT_GET,
"get" },
798 END_OF_MSGTYPES_LIST,
800 .co_protocol = NETLINK_ROUTE,
801 .co_request_update = neightbl_request_update,
802 .co_msg_parser = neightbl_msg_parser,
803 .co_obj_ops = &neightbl_obj_ops,
806static void __init neightbl_init(
void)
811static void __exit neightbl_exit(
void)
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
int nla_put_nested(struct nl_msg *msg, int attrtype, const struct nl_msg *nested)
Add nested attributes to netlink message.
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
Copy string attribute payload to a buffer.
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, const struct nla_policy *policy)
Create attribute index based on nested attribute.
#define NLA_PUT_STRING(msg, attrtype, value)
Add string attribute to netlink message.
#define NLA_PUT_U64(msg, attrtype, value)
Add 64 bit integer attribute to netlink message.
@ NLA_STRING
NUL terminated character string.
@ NLA_NESTED
Nested attributes.
int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
Unregister a set of cache operations.
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
struct nl_cache * nl_cache_mngt_require_safe(const char *name)
Return cache previously provided via nl_cache_mngt_provide()
int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_sock *sock, struct nl_cache **result)
Allocate new cache and fill it.
char * rtnl_link_i2name(struct nl_cache *cache, int ifindex, char *dst, size_t len)
Translate interface index to corresponding link name.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
void nlmsg_free(struct nl_msg *msg)
Release a reference from an netlink message.
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy)
parse attributes of a netlink message
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
void rtnl_neightbl_set_proxy_delay(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the proxy delay of a neighbour table to the specified value.
int rtnl_neightbl_change(struct nl_sock *sk, struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
Change neighbour table attributes.
struct rtnl_neightbl * rtnl_neightbl_get(struct nl_cache *cache, const char *name, int ifindex)
Lookup neighbour table by name and optional interface index.
void rtnl_neightbl_set_locktime(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the locktime of a neighbour table to the specified value.
int rtnl_neightbl_build_change_request(struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl, struct nl_msg **result)
Builds a netlink change request message to change neighbour table attributes.
void rtnl_neightbl_set_gc_stale_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the gc stale time of a neighbour table to the specified value.
void rtnl_neightbl_set_queue_len(struct rtnl_neightbl *ntbl, int len)
Set the queue length for pending requests of a neighbour table to the specified value.
int rtnl_neightbl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
Build a neighbour table cache including all neighbour tables currently configured in the kernel.
void rtnl_neightbl_set_app_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of application probes of a neighbour table to the specified value.
void rtnl_neightbl_set_anycast_delay(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the anycast delay of a neighbour table to the specified value.
void rtnl_neightbl_set_delay_probe_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the first probe delay time of a neighbour table to the specified value.
void rtnl_neightbl_set_retrans_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the retransmit time of a neighbour table to the specified value.
void rtnl_neightbl_set_mcast_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of multicast probes of a neighbour table to the specified value.
void rtnl_neightbl_set_proxy_queue_len(struct rtnl_neightbl *ntbl, int len)
Set the queue length for delay proxy arp requests of a neighbour table to the specified value.
void rtnl_neightbl_set_base_reachable_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the base reachable time of a neighbour table to the specified value.
void rtnl_neightbl_set_ucast_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of unicast probes of a neighbour table to the specified value.
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
Send routing netlink request message.
int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
char * nl_msec2str(uint64_t msec, char *buf, size_t len)
Convert milliseconds to a character string.
@ NL_DUMP_STATS
Dump all attributes including statistics.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Attribute validation policy.
uint16_t type
Type of attribute or NLA_UNSPEC.