153 #include <netlink-private/netlink.h> 154 #include <netlink/netlink.h> 155 #include <netlink/utils.h> 156 #include <netlink/hashtable.h> 157 #include <netlink/route/rtnl.h> 158 #include <netlink/route/neighbour.h> 159 #include <netlink/route/link.h> 160 #include <netlink/hashtable.h> 163 #define NEIGH_ATTR_FLAGS 0x01 164 #define NEIGH_ATTR_STATE 0x02 165 #define NEIGH_ATTR_LLADDR 0x04 166 #define NEIGH_ATTR_DST 0x08 167 #define NEIGH_ATTR_CACHEINFO 0x10 168 #define NEIGH_ATTR_IFINDEX 0x20 169 #define NEIGH_ATTR_FAMILY 0x40 170 #define NEIGH_ATTR_TYPE 0x80 171 #define NEIGH_ATTR_PROBES 0x100 172 #define NEIGH_ATTR_MASTER 0x200 173 #define NEIGH_ATTR_VLAN 0x400 175 static struct nl_cache_ops rtnl_neigh_ops;
176 static struct nl_object_ops neigh_obj_ops;
179 static void neigh_free_data(
struct nl_object *c)
181 struct rtnl_neigh *neigh = nl_object_priv(c);
190 static int neigh_clone(
struct nl_object *_dst,
struct nl_object *_src)
192 struct rtnl_neigh *dst = nl_object_priv(_dst);
193 struct rtnl_neigh *src = nl_object_priv(_src);
206 static void neigh_keygen(
struct nl_object *obj, uint32_t *hashkey,
209 struct rtnl_neigh *neigh = (
struct rtnl_neigh *) obj;
210 unsigned int nkey_sz;
211 struct nl_addr *addr = NULL;
212 struct neigh_hash_key {
217 } __attribute__((packed)) *nkey;
219 char buf[INET6_ADDRSTRLEN+5];
222 if (neigh->n_family == AF_BRIDGE) {
224 addr = neigh->n_lladdr;
225 }
else if (neigh->n_dst) {
229 nkey_sz =
sizeof(*nkey);
233 nkey = calloc(1, nkey_sz);
238 nkey->n_family = neigh->n_family;
239 if (neigh->n_family == AF_BRIDGE) {
240 nkey->n_vlan = neigh->n_vlan;
241 if (neigh->n_flags & NTF_SELF)
242 nkey->n_ifindex = neigh->n_ifindex;
244 nkey->n_ifindex = neigh->n_master;
246 nkey->n_ifindex = neigh->n_ifindex;
253 *hashkey = nl_hash(nkey, nkey_sz, 0) % table_sz;
255 NL_DBG(5,
"neigh %p key (fam %d dev %d addr %s) keysz %d hash 0x%x\n",
256 neigh, nkey->n_family, nkey->n_ifindex,
265 static uint64_t neigh_compare(
struct nl_object *_a,
struct nl_object *_b,
266 uint64_t attrs,
int flags)
268 struct rtnl_neigh *a = (
struct rtnl_neigh *) _a;
269 struct rtnl_neigh *b = (
struct rtnl_neigh *) _b;
272 #define NEIGH_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGH_ATTR_##ATTR, a, b, EXPR) 274 diff |= NEIGH_DIFF(IFINDEX, a->n_ifindex != b->n_ifindex);
275 diff |= NEIGH_DIFF(FAMILY, a->n_family != b->n_family);
276 diff |= NEIGH_DIFF(TYPE, a->n_type != b->n_type);
277 diff |= NEIGH_DIFF(LLADDR,
nl_addr_cmp(a->n_lladdr, b->n_lladdr));
278 diff |= NEIGH_DIFF(DST,
nl_addr_cmp(a->n_dst, b->n_dst));
279 diff |= NEIGH_DIFF(MASTER, a->n_master != b->n_master);
280 diff |= NEIGH_DIFF(VLAN, a->n_vlan != b->n_vlan);
282 if (flags & LOOSE_COMPARISON) {
283 diff |= NEIGH_DIFF(STATE,
284 (a->n_state ^ b->n_state) & b->n_state_mask);
285 diff |= NEIGH_DIFF(FLAGS,
286 (a->n_flags ^ b->n_flags) & b->n_flag_mask);
288 diff |= NEIGH_DIFF(STATE, a->n_state != b->n_state);
289 diff |= NEIGH_DIFF(FLAGS, a->n_flags != b->n_flags);
297 static const struct trans_tbl neigh_attrs[] = {
298 __ADD(NEIGH_ATTR_FLAGS, flags),
299 __ADD(NEIGH_ATTR_STATE, state),
300 __ADD(NEIGH_ATTR_LLADDR, lladdr),
301 __ADD(NEIGH_ATTR_DST, dst),
302 __ADD(NEIGH_ATTR_CACHEINFO, cacheinfo),
303 __ADD(NEIGH_ATTR_IFINDEX, ifindex),
304 __ADD(NEIGH_ATTR_FAMILY, family),
305 __ADD(NEIGH_ATTR_TYPE, type),
306 __ADD(NEIGH_ATTR_PROBES, probes),
307 __ADD(NEIGH_ATTR_MASTER, master),
308 __ADD(NEIGH_ATTR_VLAN, vlan),
311 static char *neigh_attrs2str(
int attrs,
char *buf,
size_t len)
313 return __flags2str(attrs, buf, len, neigh_attrs,
314 ARRAY_SIZE(neigh_attrs));
317 static uint32_t neigh_id_attrs_get(
struct nl_object *obj)
319 struct rtnl_neigh *neigh = (
struct rtnl_neigh *)obj;
321 if (neigh->n_family == AF_BRIDGE) {
322 if (neigh->n_flags & NTF_SELF)
323 return (NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY | NEIGH_ATTR_IFINDEX |
324 ((neigh->ce_mask & NEIGH_ATTR_DST) ? NEIGH_ATTR_DST: 0) |
325 ((neigh->ce_mask & NEIGH_ATTR_VLAN) ? NEIGH_ATTR_VLAN : 0));
327 return (NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY | NEIGH_ATTR_MASTER | NEIGH_ATTR_VLAN);
329 return neigh_obj_ops.oo_id_attrs;
332 static struct nla_policy neigh_policy[NDA_MAX+1] = {
333 [NDA_CACHEINFO] = { .
minlen =
sizeof(
struct nda_cacheinfo) },
334 [NDA_PROBES] = { .type =
NLA_U32 },
337 static int neigh_msg_parser(
struct nl_cache_ops *ops,
struct sockaddr_nl *who,
338 struct nlmsghdr *n,
struct nl_parser_param *pp)
340 struct rtnl_neigh *neigh;
343 if ((err = rtnl_neigh_parse(n, &neigh)) < 0)
346 err = pp->pp_cb((
struct nl_object *) neigh, pp);
348 rtnl_neigh_put(neigh);
353 int rtnl_neigh_parse(
struct nlmsghdr *n,
struct rtnl_neigh **result)
355 struct rtnl_neigh *neigh;
356 struct nlattr *tb[NDA_MAX + 1];
360 neigh = rtnl_neigh_alloc();
366 neigh->ce_msgtype = n->nlmsg_type;
369 err =
nlmsg_parse(n,
sizeof(*nm), tb, NDA_MAX, neigh_policy);
373 neigh->n_family = nm->ndm_family;
374 neigh->n_ifindex = nm->ndm_ifindex;
375 neigh->n_state = nm->ndm_state;
376 neigh->n_flags = nm->ndm_flags;
377 neigh->n_type = nm->ndm_type;
379 neigh->ce_mask |= (NEIGH_ATTR_FAMILY | NEIGH_ATTR_IFINDEX |
380 NEIGH_ATTR_STATE | NEIGH_ATTR_FLAGS |
383 if (tb[NDA_LLADDR]) {
385 if (!neigh->n_lladdr) {
391 neigh->ce_mask |= NEIGH_ATTR_LLADDR;
402 neigh->ce_mask |= NEIGH_ATTR_DST;
405 if (tb[NDA_CACHEINFO]) {
406 struct nda_cacheinfo *ci =
nla_data(tb[NDA_CACHEINFO]);
408 neigh->n_cacheinfo.nci_confirmed = ci->ndm_confirmed;
409 neigh->n_cacheinfo.nci_used = ci->ndm_used;
410 neigh->n_cacheinfo.nci_updated = ci->ndm_updated;
411 neigh->n_cacheinfo.nci_refcnt = ci->ndm_refcnt;
413 neigh->ce_mask |= NEIGH_ATTR_CACHEINFO;
416 if (tb[NDA_PROBES]) {
418 neigh->ce_mask |= NEIGH_ATTR_PROBES;
423 neigh->ce_mask |= NEIGH_ATTR_VLAN;
429 if (neigh->n_family == AF_BRIDGE) {
430 if (tb[NDA_MASTER]) {
432 neigh->ce_mask |= NEIGH_ATTR_MASTER;
439 neigh->n_master = link->l_master;
441 neigh->ce_mask |= NEIGH_ATTR_MASTER;
443 nl_cache_put(lcache);
452 rtnl_neigh_put(neigh);
456 static int neigh_request_update(
struct nl_cache *c,
struct nl_sock *h)
458 int family = c->c_iarg1;
460 if (family == AF_UNSPEC) {
462 }
else if (family == AF_BRIDGE) {
463 struct ifinfomsg hdr = {.ifi_family = family};
472 if (
nlmsg_append(msg, &hdr,
sizeof(hdr), NLMSG_ALIGNTO) < 0)
473 goto nla_put_failure;
488 static void neigh_dump_line(
struct nl_object *a,
struct nl_dump_params *p)
490 char dst[INET6_ADDRSTRLEN+5], lladdr[INET6_ADDRSTRLEN+5];
491 struct rtnl_neigh *n = (
struct rtnl_neigh *) a;
492 struct nl_cache *link_cache;
493 char state[128], flags[64];
498 if (n->n_family != AF_UNSPEC)
499 nl_dump_line(p,
"%s ", nl_af2str(n->n_family, buf,
sizeof(buf)));
501 if (n->ce_mask & NEIGH_ATTR_DST)
502 nl_dump_line(p,
"%s ",
nl_addr2str(n->n_dst, dst,
sizeof(dst)));
507 state,
sizeof(state)));
509 nl_dump(p,
"dev %d ", n->n_ifindex);
511 if (n->ce_mask & NEIGH_ATTR_LLADDR)
515 if (n->ce_mask & NEIGH_ATTR_VLAN)
516 nl_dump(p,
"vlan %d ", n->n_vlan);
518 if (n->ce_mask & NEIGH_ATTR_MASTER) {
521 state,
sizeof(state)));
523 nl_dump(p,
"%d ", n->n_master);
526 rtnl_neigh_state2str(n->n_state, state,
sizeof(state));
527 rtnl_neigh_flags2str(n->n_flags, flags,
sizeof(flags));
532 nl_dump(p,
"%s%s", state[0] ?
"," :
"<", flags);
533 if (state[0] || flags[0])
538 nl_cache_put(link_cache);
541 static void neigh_dump_details(
struct nl_object *a,
struct nl_dump_params *p)
544 struct rtnl_neigh *n = (
struct rtnl_neigh *) a;
547 neigh_dump_line(a, p);
549 nl_dump_line(p,
" refcnt %u type %s confirmed %u used " 551 n->n_cacheinfo.nci_refcnt,
552 nl_rtntype2str(n->n_type, rtn_type,
sizeof(rtn_type)),
553 n->n_cacheinfo.nci_confirmed/hz,
554 n->n_cacheinfo.nci_used/hz, n->n_cacheinfo.nci_updated/hz);
557 static void neigh_dump_stats(
struct nl_object *a,
struct nl_dump_params *p)
559 neigh_dump_details(a, p);
567 struct rtnl_neigh *rtnl_neigh_alloc(
void)
572 void rtnl_neigh_put(
struct rtnl_neigh *neigh)
613 struct nl_cache * cache;
642 struct rtnl_neigh *neigh;
644 nl_list_for_each_entry(neigh, &cache->c_items, ce_list) {
645 if (neigh->n_ifindex == ifindex &&
646 neigh->n_family == dst->a_family &&
666 struct nl_addr *lladdr,
int vlan)
668 struct rtnl_neigh *neigh;
670 nl_list_for_each_entry(neigh, &cache->c_items, ce_list) {
671 if (neigh->n_ifindex == ifindex &&
672 neigh->n_vlan == vlan &&
673 neigh->n_lladdr && !
nl_addr_cmp(neigh->n_lladdr, lladdr)) {
689 static int build_neigh_msg(
struct rtnl_neigh *tmpl,
int cmd,
int flags,
690 struct nl_msg **result)
693 struct ndmsg nhdr = {
694 .ndm_ifindex = tmpl->n_ifindex,
695 .ndm_state = NUD_PERMANENT,
698 if (tmpl->n_family != AF_BRIDGE) {
699 if (!(tmpl->ce_mask & NEIGH_ATTR_DST))
700 return -NLE_MISSING_ATTR;
704 nhdr.ndm_family = AF_BRIDGE;
706 if (tmpl->ce_mask & NEIGH_ATTR_FLAGS)
707 nhdr.ndm_flags = tmpl->n_flags;
709 if (tmpl->ce_mask & NEIGH_ATTR_STATE)
710 nhdr.ndm_state = tmpl->n_state;
716 if (
nlmsg_append(msg, &nhdr,
sizeof(nhdr), NLMSG_ALIGNTO) < 0)
717 goto nla_put_failure;
719 if (tmpl->n_family != AF_BRIDGE)
722 if (tmpl->ce_mask & NEIGH_ATTR_LLADDR)
725 if (tmpl->ce_mask & NEIGH_ATTR_VLAN)
757 struct nl_msg **result)
759 return build_neigh_msg(tmpl, RTM_NEWNEIGH, flags, result);
793 return wait_for_ack(sk);
818 struct nl_msg **result)
820 return build_neigh_msg(neigh, RTM_DELNEIGH, flags, result);
849 return wait_for_ack(sk);
859 static const struct trans_tbl neigh_states[] = {
860 __ADD(NUD_INCOMPLETE, incomplete),
861 __ADD(NUD_REACHABLE, reachable),
862 __ADD(NUD_STALE, stale),
863 __ADD(NUD_DELAY, delay),
864 __ADD(NUD_PROBE, probe),
865 __ADD(NUD_FAILED, failed),
866 __ADD(NUD_NOARP, noarp),
867 __ADD(NUD_PERMANENT, permanent),
872 __ADD(NUD_NOARP, norarp),
875 char * rtnl_neigh_state2str(
int state,
char *buf,
size_t len)
877 return __flags2str(state, buf, len, neigh_states,
878 ARRAY_SIZE(neigh_states) - 1);
881 int rtnl_neigh_str2state(
const char *name)
883 return __str2type(name, neigh_states, ARRAY_SIZE(neigh_states));
893 static const struct trans_tbl neigh_flags[] = {
895 __ADD(NTF_PROXY, proxy),
896 __ADD(NTF_ROUTER, router),
897 __ADD(NTF_SELF,
self),
898 __ADD(NTF_MASTER, master),
899 __ADD(NTF_EXT_LEARNED, ext_learned),
900 __ADD(NTF_OFFLOADED, offloaded),
903 char * rtnl_neigh_flags2str(
int flags,
char *buf,
size_t len)
905 return __flags2str(flags, buf, len, neigh_flags,
906 ARRAY_SIZE(neigh_flags));
909 int rtnl_neigh_str2flag(
const char *name)
911 return __str2type(name, neigh_flags, ARRAY_SIZE(neigh_flags));
921 void rtnl_neigh_set_state(
struct rtnl_neigh *neigh,
int state)
923 neigh->n_state_mask |= state;
924 neigh->n_state |= state;
925 neigh->ce_mask |= NEIGH_ATTR_STATE;
928 int rtnl_neigh_get_state(
struct rtnl_neigh *neigh)
930 if (neigh->ce_mask & NEIGH_ATTR_STATE)
931 return neigh->n_state;
936 void rtnl_neigh_unset_state(
struct rtnl_neigh *neigh,
int state)
938 neigh->n_state_mask |= state;
939 neigh->n_state &= ~state;
940 neigh->ce_mask |= NEIGH_ATTR_STATE;
943 void rtnl_neigh_set_flags(
struct rtnl_neigh *neigh,
unsigned int flags)
945 neigh->n_flag_mask |= flags;
946 neigh->n_flags |= flags;
947 neigh->ce_mask |= NEIGH_ATTR_FLAGS;
950 unsigned int rtnl_neigh_get_flags(
struct rtnl_neigh *neigh)
952 return neigh->n_flags;
955 void rtnl_neigh_unset_flags(
struct rtnl_neigh *neigh,
unsigned int flags)
957 neigh->n_flag_mask |= flags;
958 neigh->n_flags &= ~flags;
959 neigh->ce_mask |= NEIGH_ATTR_FLAGS;
962 void rtnl_neigh_set_ifindex(
struct rtnl_neigh *neigh,
int ifindex)
964 neigh->n_ifindex = ifindex;
965 neigh->ce_mask |= NEIGH_ATTR_IFINDEX;
968 int rtnl_neigh_get_ifindex(
struct rtnl_neigh *neigh)
970 return neigh->n_ifindex;
973 static inline int __assign_addr(
struct rtnl_neigh *neigh,
struct nl_addr **pos,
974 struct nl_addr *
new,
int flag,
int nocheck)
977 if (neigh->ce_mask & NEIGH_ATTR_FAMILY) {
978 if (new->a_family != neigh->n_family)
979 return -NLE_AF_MISMATCH;
981 neigh->n_family =
new->a_family;
982 neigh->ce_mask |= NEIGH_ATTR_FAMILY;
992 neigh->ce_mask |= flag;
997 void rtnl_neigh_set_lladdr(
struct rtnl_neigh *neigh,
struct nl_addr *addr)
999 __assign_addr(neigh, &neigh->n_lladdr, addr, NEIGH_ATTR_LLADDR, 1);
1002 struct nl_addr *rtnl_neigh_get_lladdr(
struct rtnl_neigh *neigh)
1004 if (neigh->ce_mask & NEIGH_ATTR_LLADDR)
1005 return neigh->n_lladdr;
1010 int rtnl_neigh_set_dst(
struct rtnl_neigh *neigh,
struct nl_addr *addr)
1012 return __assign_addr(neigh, &neigh->n_dst, addr,
1016 struct nl_addr *rtnl_neigh_get_dst(
struct rtnl_neigh *neigh)
1018 if (neigh->ce_mask & NEIGH_ATTR_DST)
1019 return neigh->n_dst;
1024 void rtnl_neigh_set_family(
struct rtnl_neigh *neigh,
int family)
1026 neigh->n_family = family;
1027 neigh->ce_mask |= NEIGH_ATTR_FAMILY;
1030 int rtnl_neigh_get_family(
struct rtnl_neigh *neigh)
1032 return neigh->n_family;
1035 void rtnl_neigh_set_type(
struct rtnl_neigh *neigh,
int type)
1037 neigh->n_type = type;
1038 neigh->ce_mask = NEIGH_ATTR_TYPE;
1041 int rtnl_neigh_get_type(
struct rtnl_neigh *neigh)
1043 if (neigh->ce_mask & NEIGH_ATTR_TYPE)
1044 return neigh->n_type;
1049 void rtnl_neigh_set_vlan(
struct rtnl_neigh *neigh,
int vlan)
1051 neigh->n_vlan = vlan;
1052 neigh->ce_mask |= NEIGH_ATTR_VLAN;
1055 int rtnl_neigh_get_vlan(
struct rtnl_neigh *neigh)
1057 if (neigh->ce_mask & NEIGH_ATTR_VLAN)
1058 return neigh->n_vlan;
1063 void rtnl_neigh_set_master(
struct rtnl_neigh *neigh,
int ifindex)
1065 neigh->n_master = ifindex;
1066 neigh->ce_mask |= NEIGH_ATTR_MASTER;
1069 int rtnl_neigh_get_master(
struct rtnl_neigh *neigh) {
1070 return neigh->n_master;
1075 static struct nl_object_ops neigh_obj_ops = {
1076 .oo_name =
"route/neigh",
1077 .oo_size =
sizeof(
struct rtnl_neigh),
1078 .oo_free_data = neigh_free_data,
1079 .oo_clone = neigh_clone,
1085 .oo_compare = neigh_compare,
1086 .oo_keygen = neigh_keygen,
1087 .oo_attrs2str = neigh_attrs2str,
1088 .oo_id_attrs = (NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY),
1089 .oo_id_attrs_get = neigh_id_attrs_get
1092 static struct nl_af_group neigh_groups[] = {
1093 { AF_UNSPEC, RTNLGRP_NEIGH },
1094 { AF_BRIDGE, RTNLGRP_NEIGH },
1095 { END_OF_GROUP_LIST },
1098 static struct nl_cache_ops rtnl_neigh_ops = {
1099 .co_name =
"route/neigh",
1100 .co_hdrsize =
sizeof(
struct ndmsg),
1102 { RTM_NEWNEIGH, NL_ACT_NEW,
"new" },
1103 { RTM_DELNEIGH, NL_ACT_DEL,
"del" },
1104 { RTM_GETNEIGH, NL_ACT_GET,
"get" },
1105 END_OF_MSGTYPES_LIST,
1107 .co_protocol = NETLINK_ROUTE,
1108 .co_groups = neigh_groups,
1109 .co_request_update = neigh_request_update,
1110 .co_msg_parser = neigh_msg_parser,
1111 .co_obj_ops = &neigh_obj_ops,
1114 static void __init neigh_init(
void)
1119 static void __exit neigh_exit(
void)
int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
struct nl_addr * nl_addr_clone(const struct nl_addr *addr)
Clone existing abstract address object.
Dump object briefly on one line.
int nl_get_user_hz(void)
Return the value of HZ.
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
int nl_addr_cmp(const struct nl_addr *a, const struct nl_addr *b)
Compare abstract addresses.
int nl_addr_guess_family(const struct nl_addr *addr)
Guess address family of abstract address based on address size.
int rtnl_neigh_delete(struct nl_sock *sk, struct rtnl_neigh *neigh, int flags)
Delete a neighbour.
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
#define NLA_PUT_ADDR(msg, attrtype, addr)
Add address attribute to netlink message.
struct rtnl_link * rtnl_link_get(struct nl_cache *cache, int ifindex)
Lookup link in cache by interface index.
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.
struct nl_cache * nl_cache_mngt_require_safe(const char *name)
Return cache previously provided via nl_cache_mngt_provide()
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
int rtnl_neigh_alloc_cache_flags(struct nl_sock *sock, struct nl_cache **result, unsigned int flags)
Build a neighbour cache including all neighbours currently configured in the kernel.
struct rtnl_neigh * rtnl_neigh_get_by_vlan(struct nl_cache *cache, int ifindex, struct nl_addr *lladdr, int vlan)
Look up a neighbour by interface index, link layer address and vlan id.
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
struct nl_addr * nl_addr_get(struct nl_addr *addr)
Increase the reference counter of an abstract address.
void nl_addr_set_family(struct nl_addr *addr, int family)
Set address family.
struct nl_addr * nl_addr_alloc_attr(const struct nlattr *nla, int family)
Allocate abstract address based on Netlink attribute.
int rtnl_neigh_add(struct nl_sock *sk, struct rtnl_neigh *tmpl, int flags)
Add a new neighbour.
Dump all attributes but no statistics.
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.
struct rtnl_neigh * rtnl_neigh_get(struct nl_cache *cache, int ifindex, struct nl_addr *dst)
Look up a neighbour by interface index and destination address.
int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags, struct nl_msg **result)
Build a netlink request message to delete a neighbour.
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
Send routing netlink request message.
void * nla_data(const struct nlattr *nla)
Return pointer to the payload section.
int rtnl_neigh_build_add_request(struct rtnl_neigh *tmpl, int flags, struct nl_msg **result)
Build netlink request message to add a new neighbour.
int rtnl_neigh_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
Build a neighbour cache including all neighbours currently configured in the kernel.
uint16_t minlen
Minimal length of payload required.
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
(Re)fill a cache with the contents in the kernel.
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
void nl_addr_put(struct nl_addr *addr)
Decrease the reference counter of an abstract address.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
uint16_t nla_get_u16(const struct nlattr *nla)
Return payload of 16 bit integer attribute.
char * rtnl_link_i2name(struct nl_cache *cache, int ifindex, char *dst, size_t len)
Translate interface index to corresponding link name.
#define NLA_PUT_U16(msg, attrtype, value)
Add 16 bit integer attribute to netlink message.
void nl_cache_set_flags(struct nl_cache *cache, unsigned int flags)
Set cache flags.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
void rtnl_link_put(struct rtnl_link *link)
Return a link object reference.
int nl_send_auto(struct nl_sock *sk, struct nl_msg *msg)
Finalize and transmit Netlink message.
unsigned int nl_addr_get_len(const struct nl_addr *addr)
Get length of binary address of abstract address object.
Dump all attributes including statistics.
void * nl_addr_get_binary_addr(const struct nl_addr *addr)
Get binary address of abstract address object.
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.
struct nl_cache * nl_cache_alloc(struct nl_cache_ops *ops)
Allocate new cache.
char * nl_addr2str(const struct nl_addr *addr, char *buf, size_t size)
Convert abstract address object to character string.
int nl_addr_get_family(const struct nl_addr *addr)
Return address family.