19 #include <netlink-local.h> 20 #include <netlink/netlink.h> 21 #include <netlink/utils.h> 22 #include <netlink/route/rtnl.h> 23 #include <netlink/route/neightbl.h> 24 #include <netlink/route/link.h> 27 #define NEIGHTBL_ATTR_FAMILY 0x001 28 #define NEIGHTBL_ATTR_STATS 0x002 29 #define NEIGHTBL_ATTR_NAME 0x004 30 #define NEIGHTBL_ATTR_THRESH1 0x008 31 #define NEIGHTBL_ATTR_THRESH2 0x010 32 #define NEIGHTBL_ATTR_THRESH3 0x020 33 #define NEIGHTBL_ATTR_CONFIG 0x040 34 #define NEIGHTBL_ATTR_PARMS 0x080 35 #define NEIGHTBL_ATTR_GC_INTERVAL 0x100 37 #define NEIGHTBLPARM_ATTR_IFINDEX 0x0001 38 #define NEIGHTBLPARM_ATTR_REFCNT 0x0002 39 #define NEIGHTBLPARM_ATTR_QUEUE_LEN 0x0004 40 #define NEIGHTBLPARM_ATTR_APP_PROBES 0x0008 41 #define NEIGHTBLPARM_ATTR_UCAST_PROBES 0x0010 42 #define NEIGHTBLPARM_ATTR_MCAST_PROBES 0x0020 43 #define NEIGHTBLPARM_ATTR_PROXY_QLEN 0x0040 44 #define NEIGHTBLPARM_ATTR_REACHABLE_TIME 0x0080 45 #define NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME 0x0100 46 #define NEIGHTBLPARM_ATTR_RETRANS_TIME 0x0200 47 #define NEIGHTBLPARM_ATTR_GC_STALETIME 0x0400 48 #define NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME 0x0800 49 #define NEIGHTBLPARM_ATTR_ANYCAST_DELAY 0x1000 50 #define NEIGHTBLPARM_ATTR_PROXY_DELAY 0x2000 51 #define NEIGHTBLPARM_ATTR_LOCKTIME 0x4000 57 static int neightbl_compare(
struct nl_object *_a,
struct nl_object *_b,
58 uint32_t attrs,
int flags)
60 struct rtnl_neightbl *a = (
struct rtnl_neightbl *) _a;
61 struct rtnl_neightbl *b = (
struct rtnl_neightbl *) _b;
64 #define NT_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGHTBL_ATTR_##ATTR, a, b, EXPR) 66 diff |= NT_DIFF(FAMILY, a->nt_family != b->nt_family);
67 diff |= NT_DIFF(NAME, strcmp(a->nt_name, b->nt_name));
68 diff |= NT_DIFF(THRESH1, a->nt_gc_thresh1 != b->nt_gc_thresh1);
69 diff |= NT_DIFF(THRESH2, a->nt_gc_thresh2 != b->nt_gc_thresh2);
70 diff |= NT_DIFF(THRESH3, a->nt_gc_thresh3 != b->nt_gc_thresh3);
71 diff |= NT_DIFF(GC_INTERVAL, a->nt_gc_interval != b->nt_gc_interval);
75 if (!(a->ce_mask & NEIGHTBL_ATTR_PARMS) &&
76 !(b->ce_mask & NEIGHTBL_ATTR_PARMS))
83 #define REQ(F) (fp->ntp_mask & NEIGHTBLPARM_ATTR_##F) 84 #define AVAIL(F) (op->ntp_mask & NEIGHTBLPARM_ATTR_##F) 85 #define _C(F, N) (REQ(F) && (!AVAIL(F) || (op->N != fp->N))) 86 if (_C(IFINDEX, ntp_ifindex) ||
87 _C(QUEUE_LEN, ntp_queue_len) ||
88 _C(APP_PROBES, ntp_app_probes) ||
89 _C(UCAST_PROBES, ntp_ucast_probes) ||
90 _C(MCAST_PROBES, ntp_mcast_probes) ||
91 _C(PROXY_QLEN, ntp_proxy_qlen) ||
92 _C(LOCKTIME, ntp_locktime) ||
93 _C(RETRANS_TIME, ntp_retrans_time) ||
94 _C(BASE_REACHABLE_TIME, ntp_base_reachable_time) ||
95 _C(GC_STALETIME, ntp_gc_stale_time) ||
96 _C(DELAY_PROBE_TIME, ntp_probe_delay) ||
97 _C(ANYCAST_DELAY, ntp_anycast_delay) ||
98 _C(PROXY_DELAY, ntp_proxy_delay))
109 static struct nla_policy neightbl_policy[NDTA_MAX+1] = {
111 .maxlen = NTBLNAMSIZ },
112 [NDTA_THRESH1] = { .type =
NLA_U32 },
113 [NDTA_THRESH2] = { .type =
NLA_U32 },
114 [NDTA_THRESH3] = { .type =
NLA_U32 },
115 [NDTA_GC_INTERVAL] = { .type =
NLA_U32 },
116 [NDTA_CONFIG] = { .minlen =
sizeof(
struct ndt_config) },
117 [NDTA_STATS] = { .minlen =
sizeof(
struct ndt_stats) },
121 static int neightbl_msg_parser(
struct nl_cache_ops *ops,
125 struct rtnl_neightbl *ntbl;
126 struct nlattr *tb[NDTA_MAX + 1];
127 struct rtgenmsg *rtmsg;
130 ntbl = rtnl_neightbl_alloc();
132 err = nl_errno(ENOMEM);
139 err =
nlmsg_parse(n,
sizeof(*rtmsg), tb, NDTA_MAX, neightbl_policy);
143 ntbl->nt_family = rtmsg->rtgen_family;
145 if (tb[NDTA_NAME] == NULL) {
146 err = nl_error(EINVAL,
"NDTA_NAME is missing");
150 nla_strlcpy(ntbl->nt_name, tb[NDTA_NAME], NTBLNAMSIZ);
151 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
153 if (tb[NDTA_THRESH1]) {
154 ntbl->nt_gc_thresh1 =
nla_get_u32(tb[NDTA_THRESH1]);
155 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
158 if (tb[NDTA_THRESH2]) {
159 ntbl->nt_gc_thresh2 =
nla_get_u32(tb[NDTA_THRESH2]);
160 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
163 if (tb[NDTA_THRESH3]) {
164 ntbl->nt_gc_thresh3 =
nla_get_u32(tb[NDTA_THRESH3]);
165 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
168 if (tb[NDTA_GC_INTERVAL]) {
169 ntbl->nt_gc_interval =
nla_get_u32(tb[NDTA_GC_INTERVAL]);
170 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
173 if (tb[NDTA_CONFIG]) {
175 sizeof(ntbl->nt_config));
176 ntbl->ce_mask |= NEIGHTBL_ATTR_CONFIG;
179 if (tb[NDTA_STATS]) {
181 sizeof(ntbl->nt_stats));
182 ntbl->ce_mask |= NEIGHTBL_ATTR_STATS;
185 if (tb[NDTA_PARMS]) {
186 struct nlattr *tbp[NDTPA_MAX + 1];
187 struct rtnl_neightbl_parms *p = &ntbl->nt_parms;
193 #define COPY_ENTRY(name, var) \ 194 if (tbp[NDTPA_ ##name]) { \ 195 p->ntp_ ##var = nla_get_u32(tbp[NDTPA_ ##name]); \ 196 p->ntp_mask |= NEIGHTBLPARM_ATTR_ ##name; \ 199 COPY_ENTRY(IFINDEX, ifindex);
200 COPY_ENTRY(REFCNT, refcnt);
201 COPY_ENTRY(QUEUE_LEN, queue_len);
202 COPY_ENTRY(APP_PROBES, app_probes);
203 COPY_ENTRY(UCAST_PROBES, ucast_probes);
204 COPY_ENTRY(MCAST_PROBES, mcast_probes);
205 COPY_ENTRY(PROXY_QLEN, proxy_qlen);
206 COPY_ENTRY(PROXY_DELAY, proxy_delay);
207 COPY_ENTRY(ANYCAST_DELAY, anycast_delay);
208 COPY_ENTRY(LOCKTIME, locktime);
209 COPY_ENTRY(REACHABLE_TIME, reachable_time);
210 COPY_ENTRY(BASE_REACHABLE_TIME, base_reachable_time);
211 COPY_ENTRY(RETRANS_TIME, retrans_time);
212 COPY_ENTRY(GC_STALETIME, gc_stale_time);
213 COPY_ENTRY(DELAY_PROBE_TIME, probe_delay);
216 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
219 err = pp->pp_cb((
struct nl_object *) ntbl, pp);
225 rtnl_neightbl_put(ntbl);
229 static int neightbl_request_update(
struct nl_cache *c,
struct nl_handle *h)
235 static int neightbl_dump_brief(
struct nl_object *arg,
struct nl_dump_params *p)
238 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
240 dp_dump(p,
"%s", ntbl->nt_name);
242 if (ntbl->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX) {
243 struct nl_cache *link_cache;
251 ntbl->nt_parms.ntp_ifindex,
254 dp_dump(p,
"<%u> ", ntbl->nt_parms.ntp_ifindex);
258 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG)
259 dp_dump(p,
"entries %u ", ntbl->nt_config.ndtc_entries);
261 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
262 char rt[32], rt2[32];
263 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
265 dp_dump(p,
"reachable-time %s retransmit-time %s",
266 nl_msec2str(pa->ntp_reachable_time, rt,
sizeof(rt)),
267 nl_msec2str(pa->ntp_retrans_time, rt2,
sizeof(rt2)));
275 static int neightbl_dump_full(
struct nl_object *arg,
struct nl_dump_params *p)
277 char x[32], y[32], z[32];
278 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
280 int line = neightbl_dump_brief(arg, p);
282 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG) {
283 dp_new_line(p, line++);
284 dp_dump(p,
" key-len %u entry-size %u last-flush %s\n",
285 ntbl->nt_config.ndtc_key_len,
286 ntbl->nt_config.ndtc_entry_size,
290 dp_new_line(p, line++);
291 dp_dump(p,
" gc threshold %u/%u/%u interval %s " \
292 "chain-position %u\n",
293 ntbl->nt_gc_thresh1, ntbl->nt_gc_thresh2,
296 ntbl->nt_config.ndtc_hash_chain_gc);
298 dp_new_line(p, line++);
299 dp_dump(p,
" hash-rand 0x%08X/0x%08X last-rand %s\n",
300 ntbl->nt_config.ndtc_hash_rnd,
301 ntbl->nt_config.ndtc_hash_mask,
306 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
307 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
309 dp_new_line(p, line++);
310 dp_dump(p,
" refcnt %u pending-queue-limit %u " \
311 "proxy-delayed-queue-limit %u\n",
316 dp_new_line(p, line++);
317 dp_dump(p,
" num-userspace-probes %u num-unicast-probes " \
318 "%u num-multicast-probes %u\n",
320 pa->ntp_ucast_probes,
321 pa->ntp_mcast_probes);
323 dp_new_line(p, line++);
324 dp_dump(p,
" min-age %s base-reachable-time %s " \
325 "stale-check-interval %s\n",
331 dp_new_line(p, line++);
332 dp_dump(p,
" initial-probe-delay %s answer-delay %s " \
333 "proxy-answer-delay %s\n",
342 static int neightbl_dump_stats(
struct nl_object *arg,
struct nl_dump_params *p)
344 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
345 int line = neightbl_dump_full(arg, p);
347 if (!(ntbl->ce_mask & NEIGHTBL_ATTR_STATS))
350 dp_new_line(p, line++);
351 dp_dump(p,
" lookups %lld hits %lld failed %lld " \
352 "allocations %lld destroys %lld\n",
353 ntbl->nt_stats.ndts_lookups,
354 ntbl->nt_stats.ndts_hits,
355 ntbl->nt_stats.ndts_res_failed,
356 ntbl->nt_stats.ndts_allocs,
357 ntbl->nt_stats.ndts_destroys);
359 dp_new_line(p, line++);
360 dp_dump(p,
" hash-grows %lld forced-gc-runs %lld " \
361 "periodic-gc-runs %lld\n",
362 ntbl->nt_stats.ndts_hash_grows,
363 ntbl->nt_stats.ndts_forced_gc_runs,
364 ntbl->nt_stats.ndts_periodic_gc_runs);
366 dp_dump(p,
" rcv-unicast-probes %lld rcv-multicast-probes %lld\n",
367 ntbl->nt_stats.ndts_rcv_probes_ucast,
368 ntbl->nt_stats.ndts_rcv_probes_mcast);
378 struct rtnl_neightbl *rtnl_neightbl_alloc(
void)
383 void rtnl_neightbl_put(
struct rtnl_neightbl *neightbl)
409 struct nl_cache * cache;
437 const char *name,
int ifindex)
439 struct rtnl_neightbl *nt;
441 if (cache->c_ops != &rtnl_neightbl_ops)
444 nl_list_for_each_entry(nt, &cache->c_items, ce_list) {
445 if (!strcasecmp(nt->nt_name, name) &&
446 ((!ifindex && !nt->nt_parms.ntp_ifindex) ||
447 (ifindex && ifindex == nt->nt_parms.ntp_ifindex))) {
479 struct rtnl_neightbl *tmpl)
482 struct ndtmsg ndt = {
483 .ndtm_family = old->nt_family,
491 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH1)
494 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
497 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
500 if (tmpl->ce_mask & NEIGHTBL_ATTR_GC_INTERVAL)
502 tmpl->nt_gc_interval);
504 if (tmpl->ce_mask & NEIGHTBL_ATTR_PARMS) {
505 struct rtnl_neightbl_parms *p = &tmpl->nt_parms;
508 if (old->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX)
510 old->nt_parms.ntp_ifindex);
513 if (p->ntp_mask & NEIGHTBLPARM_ATTR_QUEUE_LEN)
514 nla_put_u32(parms, NDTPA_QUEUE_LEN, p->ntp_queue_len);
516 if (p->ntp_mask & NEIGHTBLPARM_ATTR_APP_PROBES)
517 nla_put_u32(parms, NDTPA_APP_PROBES, p->ntp_app_probes);
519 if (p->ntp_mask & NEIGHTBLPARM_ATTR_UCAST_PROBES)
521 p->ntp_ucast_probes);
523 if (p->ntp_mask & NEIGHTBLPARM_ATTR_MCAST_PROBES)
525 p->ntp_mcast_probes);
527 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_QLEN)
531 if (p->ntp_mask & NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME)
533 p->ntp_base_reachable_time);
535 if (p->ntp_mask & NEIGHTBLPARM_ATTR_RETRANS_TIME)
537 p->ntp_retrans_time);
539 if (p->ntp_mask & NEIGHTBLPARM_ATTR_GC_STALETIME)
541 p->ntp_gc_stale_time);
543 if (p->ntp_mask & NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME)
547 if (p->ntp_mask & NEIGHTBLPARM_ATTR_ANYCAST_DELAY)
549 p->ntp_anycast_delay);
551 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_DELAY)
555 if (p->ntp_mask & NEIGHTBLPARM_ATTR_LOCKTIME)
556 nla_put_u64(parms, NDTPA_LOCKTIME, p->ntp_locktime);
579 struct rtnl_neightbl *tmpl)
600 void rtnl_neightbl_set_family(
struct rtnl_neightbl *ntbl,
int family)
602 ntbl->nt_family = family;
603 ntbl->ce_mask |= NEIGHTBL_ATTR_FAMILY;
606 void rtnl_neightbl_set_gc_interval(
struct rtnl_neightbl *ntbl, uint64_t ms)
608 ntbl->nt_gc_interval = ms;
609 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
612 void rtnl_neightbl_set_gc_tresh1(
struct rtnl_neightbl *ntbl,
int thresh)
614 ntbl->nt_gc_thresh1 = thresh;
615 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
618 void rtnl_neightbl_set_gc_tresh2(
struct rtnl_neightbl *ntbl,
int thresh)
620 ntbl->nt_gc_thresh2 = thresh;
621 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
624 void rtnl_neightbl_set_gc_tresh3(
struct rtnl_neightbl *ntbl,
int thresh)
626 ntbl->nt_gc_thresh3 = thresh;
627 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
630 void rtnl_neightbl_set_name(
struct rtnl_neightbl *ntbl,
const char *name)
632 strncpy(ntbl->nt_name, name,
sizeof(ntbl->nt_name) - 1);
633 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
636 void rtnl_neightbl_set_dev(
struct rtnl_neightbl *ntbl,
int ifindex)
638 ntbl->nt_parms.ntp_ifindex = ifindex;
639 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_IFINDEX;
640 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
650 ntbl->nt_parms.ntp_queue_len = len;
651 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_QUEUE_LEN;
652 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
662 ntbl->nt_parms.ntp_proxy_qlen = len;
663 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_QLEN;
664 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
674 ntbl->nt_parms.ntp_app_probes = probes;
675 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_APP_PROBES;
676 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
686 ntbl->nt_parms.ntp_ucast_probes = probes;
687 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_UCAST_PROBES;
688 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
698 ntbl->nt_parms.ntp_mcast_probes = probes;
699 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_MCAST_PROBES;
700 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
711 ntbl->nt_parms.ntp_base_reachable_time = ms;
712 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME;
713 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
723 ntbl->nt_parms.ntp_retrans_time = ms;
724 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_RETRANS_TIME;
725 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
735 ntbl->nt_parms.ntp_gc_stale_time = ms;
736 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_GC_STALETIME;
737 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
747 ntbl->nt_parms.ntp_probe_delay = ms;
748 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME;
749 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
759 ntbl->nt_parms.ntp_anycast_delay = ms;
760 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_ANYCAST_DELAY;
761 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
771 ntbl->nt_parms.ntp_proxy_delay = ms;
772 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_DELAY;
773 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
783 ntbl->nt_parms.ntp_locktime = ms;
784 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_LOCKTIME;
785 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
792 .oo_size =
sizeof(
struct rtnl_neightbl),
793 .oo_dump[NL_DUMP_BRIEF] = neightbl_dump_brief,
796 .oo_compare = neightbl_compare,
800 .co_name =
"route/neightbl",
801 .co_hdrsize =
sizeof(
struct rtgenmsg),
803 { RTM_NEWNEIGHTBL, NL_ACT_NEW,
"new" },
804 { RTM_SETNEIGHTBL, NL_ACT_SET,
"set" },
805 { RTM_GETNEIGHTBL, NL_ACT_GET,
"get" },
806 END_OF_MSGTYPES_LIST,
808 .co_protocol = NETLINK_ROUTE,
809 .co_request_update = neightbl_request_update,
810 .co_msg_parser = neightbl_msg_parser,
811 .co_obj_ops = &neightbl_obj_ops,
814 static void __init neightbl_init(
void)
819 static void __exit neightbl_exit(
void)
int nla_put_u64(struct nl_msg *n, int attrtype, uint64_t value)
Add a u64 netlink attribute to a netlink message.
int rtnl_neightbl_change(struct nl_handle *handle, struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
Change neighbour table attributes.
void * nlmsg_data(const struct nlmsghdr *nlh)
head of message payload
uint16_t nlmsg_type
Message type (content type)
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
Unregister a set of cache operations.
attribute validation policy
int nl_wait_for_ack(struct nl_handle *handle)
Wait for ACK.
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
void rtnl_neightbl_set_locktime(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the locktime of a neighbour table to the specified value.
void nlmsg_free(struct nl_msg *n)
Free a netlink message.
char * nl_msec2str(uint64_t msec, char *buf, size_t len)
Convert milliseconds to a character string.
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_app_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of application probes of a neighbour table to the specified value. ...
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, struct nla_policy *policy)
parse attributes of a netlink message
struct rtnl_neightbl * rtnl_neightbl_get(struct nl_cache *cache, const char *name, int ifindex)
Lookup neighbour table by name and optional interface index.
int nla_memcpy(void *dest, struct nlattr *src, int count)
Copy a netlink attribute into another memory area.
struct nl_msg * rtnl_neightbl_build_change_request(struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
Builds a netlink change request message to change neighbour table attributes.
int nl_send_auto_complete(struct nl_handle *handle, struct nl_msg *msg)
Send netlink message and check & extend header values as needed.
void nl_cache_free(struct nl_cache *cache)
Free a cache.
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
int nl_cache_refill(struct nl_handle *handle, struct nl_cache *cache)
(Re)fill a cache with the contents in the kernel.
#define NLM_F_DUMP
Dump all entries.
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, struct nla_policy *policy)
parse nested attributes
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.
struct nl_cache * nl_cache_mngt_require(const char *name)
Demand the use of a global cache.
int nl_rtgen_request(struct nl_handle *handle, int type, int family, int flags)
Send routing netlink request message.
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 nla_put_string(struct nl_msg *n, int attrtype, const char *str)
Add a string netlink attribute to a netlink message.
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
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_gc_stale_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the gc stale time of a neighbour table to the specified value.
uint16_t type
Type of attribute or NLA_UNSPEC.
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.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
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...
char * rtnl_link_i2name(struct nl_cache *cache, int ifindex, char *dst, size_t len)
Translate an interface index to the corresponding link name.
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.
int nla_put_nested(struct nl_msg *n, int attrtype, struct nl_msg *nested)
Add a nested netlink attribute to a netlink message.
uint32_t nla_get_u32(struct nlattr *nla)
Return payload of u32 attribute.
int nla_put_u32(struct nl_msg *n, int attrtype, uint32_t value)
Add a u32 netlink attribute to a netlink message.
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.
struct nl_cache * rtnl_neightbl_alloc_cache(struct nl_handle *handle)
Build a neighbour table cache including all neighbour tables currently configured in the kernel...
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.
char * oo_name
Unique name of object type.
Dump all attributes but no statistics.
Dump all attributes including statistics.
size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
Copy string attribute payload into a sized buffer.
struct nl_cache * nl_cache_alloc(struct nl_cache_ops *ops)
Allocate an empty cache.