Lines Matching refs:neigh
181 struct rtnl_neigh *neigh = nl_object_priv(c); in neigh_free_data() local
183 if (!neigh) in neigh_free_data()
186 nl_addr_put(neigh->n_lladdr); in neigh_free_data()
187 nl_addr_put(neigh->n_dst); in neigh_free_data()
209 struct rtnl_neigh *neigh = (struct rtnl_neigh *) obj; in neigh_keygen() local
222 if (neigh->n_family == AF_BRIDGE) { in neigh_keygen()
223 if (neigh->n_lladdr) in neigh_keygen()
224 addr = neigh->n_lladdr; in neigh_keygen()
225 } else if (neigh->n_dst) { in neigh_keygen()
226 addr = neigh->n_dst; in neigh_keygen()
238 nkey->n_family = neigh->n_family; in neigh_keygen()
239 if (neigh->n_family == AF_BRIDGE) { in neigh_keygen()
240 nkey->n_vlan = neigh->n_vlan; in neigh_keygen()
241 if (neigh->n_flags & NTF_SELF) in neigh_keygen()
242 nkey->n_ifindex = neigh->n_ifindex; in neigh_keygen()
244 nkey->n_ifindex = neigh->n_master; in neigh_keygen()
246 nkey->n_ifindex = neigh->n_ifindex; in neigh_keygen()
256 neigh, nkey->n_family, nkey->n_ifindex, in neigh_keygen()
319 struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj; in neigh_id_attrs_get() local
321 if (neigh->n_family == AF_BRIDGE) { in neigh_id_attrs_get()
322 if (neigh->n_flags & NTF_SELF) in neigh_id_attrs_get()
324 ((neigh->ce_mask & NEIGH_ATTR_DST) ? NEIGH_ATTR_DST: 0) | in neigh_id_attrs_get()
325 ((neigh->ce_mask & NEIGH_ATTR_VLAN) ? NEIGH_ATTR_VLAN : 0)); in neigh_id_attrs_get()
340 struct rtnl_neigh *neigh; in neigh_msg_parser() local
343 if ((err = rtnl_neigh_parse(n, &neigh)) < 0) in neigh_msg_parser()
346 err = pp->pp_cb((struct nl_object *) neigh, pp); in neigh_msg_parser()
348 rtnl_neigh_put(neigh); in neigh_msg_parser()
355 struct rtnl_neigh *neigh; in rtnl_neigh_parse() local
360 neigh = rtnl_neigh_alloc(); in rtnl_neigh_parse()
361 if (!neigh) { in rtnl_neigh_parse()
366 neigh->ce_msgtype = n->nlmsg_type; in rtnl_neigh_parse()
373 neigh->n_family = nm->ndm_family; in rtnl_neigh_parse()
374 neigh->n_ifindex = nm->ndm_ifindex; in rtnl_neigh_parse()
375 neigh->n_state = nm->ndm_state; in rtnl_neigh_parse()
376 neigh->n_flags = nm->ndm_flags; in rtnl_neigh_parse()
377 neigh->n_type = nm->ndm_type; in rtnl_neigh_parse()
379 neigh->ce_mask |= (NEIGH_ATTR_FAMILY | NEIGH_ATTR_IFINDEX | in rtnl_neigh_parse()
384 neigh->n_lladdr = nl_addr_alloc_attr(tb[NDA_LLADDR], AF_UNSPEC); in rtnl_neigh_parse()
385 if (!neigh->n_lladdr) { in rtnl_neigh_parse()
389 nl_addr_set_family(neigh->n_lladdr, in rtnl_neigh_parse()
390 nl_addr_guess_family(neigh->n_lladdr)); in rtnl_neigh_parse()
391 neigh->ce_mask |= NEIGH_ATTR_LLADDR; in rtnl_neigh_parse()
395 neigh->n_dst = nl_addr_alloc_attr(tb[NDA_DST], AF_UNSPEC); in rtnl_neigh_parse()
396 if (!neigh->n_dst) { in rtnl_neigh_parse()
400 nl_addr_set_family(neigh->n_dst, in rtnl_neigh_parse()
401 nl_addr_guess_family(neigh->n_dst)); in rtnl_neigh_parse()
402 neigh->ce_mask |= NEIGH_ATTR_DST; in rtnl_neigh_parse()
408 neigh->n_cacheinfo.nci_confirmed = ci->ndm_confirmed; in rtnl_neigh_parse()
409 neigh->n_cacheinfo.nci_used = ci->ndm_used; in rtnl_neigh_parse()
410 neigh->n_cacheinfo.nci_updated = ci->ndm_updated; in rtnl_neigh_parse()
411 neigh->n_cacheinfo.nci_refcnt = ci->ndm_refcnt; in rtnl_neigh_parse()
413 neigh->ce_mask |= NEIGH_ATTR_CACHEINFO; in rtnl_neigh_parse()
417 neigh->n_probes = nla_get_u32(tb[NDA_PROBES]); in rtnl_neigh_parse()
418 neigh->ce_mask |= NEIGH_ATTR_PROBES; in rtnl_neigh_parse()
422 neigh->n_vlan = nla_get_u16(tb[NDA_VLAN]); in rtnl_neigh_parse()
423 neigh->ce_mask |= NEIGH_ATTR_VLAN; in rtnl_neigh_parse()
429 if (neigh->n_family == AF_BRIDGE) { in rtnl_neigh_parse()
431 neigh->n_master = nla_get_u32(tb[NDA_MASTER]); in rtnl_neigh_parse()
432 neigh->ce_mask |= NEIGH_ATTR_MASTER; in rtnl_neigh_parse()
437 neigh->n_ifindex); in rtnl_neigh_parse()
439 neigh->n_master = link->l_master; in rtnl_neigh_parse()
441 neigh->ce_mask |= NEIGH_ATTR_MASTER; in rtnl_neigh_parse()
448 *result = neigh; in rtnl_neigh_parse()
452 rtnl_neigh_put(neigh); in rtnl_neigh_parse()
572 void rtnl_neigh_put(struct rtnl_neigh *neigh) in rtnl_neigh_put() argument
574 nl_object_put((struct nl_object *) neigh); in rtnl_neigh_put()
642 struct rtnl_neigh *neigh; in rtnl_neigh_get() local
644 nl_list_for_each_entry(neigh, &cache->c_items, ce_list) { in rtnl_neigh_get()
645 if (neigh->n_ifindex == ifindex && in rtnl_neigh_get()
646 neigh->n_family == dst->a_family && in rtnl_neigh_get()
647 !nl_addr_cmp(neigh->n_dst, dst)) { in rtnl_neigh_get()
648 nl_object_get((struct nl_object *) neigh); in rtnl_neigh_get()
649 return neigh; in rtnl_neigh_get()
668 struct rtnl_neigh *neigh; in rtnl_neigh_get_by_vlan() local
670 nl_list_for_each_entry(neigh, &cache->c_items, ce_list) { in rtnl_neigh_get_by_vlan()
671 if (neigh->n_ifindex == ifindex && in rtnl_neigh_get_by_vlan()
672 neigh->n_vlan == vlan && in rtnl_neigh_get_by_vlan()
673 neigh->n_lladdr && !nl_addr_cmp(neigh->n_lladdr, lladdr)) { in rtnl_neigh_get_by_vlan()
674 nl_object_get((struct nl_object *) neigh); in rtnl_neigh_get_by_vlan()
675 return neigh; in rtnl_neigh_get_by_vlan()
817 int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags, in rtnl_neigh_build_delete_request() argument
820 return build_neigh_msg(neigh, RTM_DELNEIGH, flags, result); in rtnl_neigh_build_delete_request()
835 int rtnl_neigh_delete(struct nl_sock *sk, struct rtnl_neigh *neigh, in rtnl_neigh_delete() argument
841 if ((err = rtnl_neigh_build_delete_request(neigh, flags, &msg)) < 0) in rtnl_neigh_delete()
921 void rtnl_neigh_set_state(struct rtnl_neigh *neigh, int state) in rtnl_neigh_set_state() argument
923 neigh->n_state_mask |= state; in rtnl_neigh_set_state()
924 neigh->n_state |= state; in rtnl_neigh_set_state()
925 neigh->ce_mask |= NEIGH_ATTR_STATE; in rtnl_neigh_set_state()
928 int rtnl_neigh_get_state(struct rtnl_neigh *neigh) in rtnl_neigh_get_state() argument
930 if (neigh->ce_mask & NEIGH_ATTR_STATE) in rtnl_neigh_get_state()
931 return neigh->n_state; in rtnl_neigh_get_state()
936 void rtnl_neigh_unset_state(struct rtnl_neigh *neigh, int state) in rtnl_neigh_unset_state() argument
938 neigh->n_state_mask |= state; in rtnl_neigh_unset_state()
939 neigh->n_state &= ~state; in rtnl_neigh_unset_state()
940 neigh->ce_mask |= NEIGH_ATTR_STATE; in rtnl_neigh_unset_state()
943 void rtnl_neigh_set_flags(struct rtnl_neigh *neigh, unsigned int flags) in rtnl_neigh_set_flags() argument
945 neigh->n_flag_mask |= flags; in rtnl_neigh_set_flags()
946 neigh->n_flags |= flags; in rtnl_neigh_set_flags()
947 neigh->ce_mask |= NEIGH_ATTR_FLAGS; in rtnl_neigh_set_flags()
950 unsigned int rtnl_neigh_get_flags(struct rtnl_neigh *neigh) in rtnl_neigh_get_flags() argument
952 return neigh->n_flags; in rtnl_neigh_get_flags()
955 void rtnl_neigh_unset_flags(struct rtnl_neigh *neigh, unsigned int flags) in rtnl_neigh_unset_flags() argument
957 neigh->n_flag_mask |= flags; in rtnl_neigh_unset_flags()
958 neigh->n_flags &= ~flags; in rtnl_neigh_unset_flags()
959 neigh->ce_mask |= NEIGH_ATTR_FLAGS; in rtnl_neigh_unset_flags()
962 void rtnl_neigh_set_ifindex(struct rtnl_neigh *neigh, int ifindex) in rtnl_neigh_set_ifindex() argument
964 neigh->n_ifindex = ifindex; in rtnl_neigh_set_ifindex()
965 neigh->ce_mask |= NEIGH_ATTR_IFINDEX; in rtnl_neigh_set_ifindex()
968 int rtnl_neigh_get_ifindex(struct rtnl_neigh *neigh) in rtnl_neigh_get_ifindex() argument
970 return neigh->n_ifindex; in rtnl_neigh_get_ifindex()
973 static inline int __assign_addr(struct rtnl_neigh *neigh, struct nl_addr **pos, in __assign_addr() argument
977 if (neigh->ce_mask & NEIGH_ATTR_FAMILY) { in __assign_addr()
978 if (new->a_family != neigh->n_family) in __assign_addr()
981 neigh->n_family = new->a_family; in __assign_addr()
982 neigh->ce_mask |= NEIGH_ATTR_FAMILY; in __assign_addr()
992 neigh->ce_mask |= flag; in __assign_addr()
997 void rtnl_neigh_set_lladdr(struct rtnl_neigh *neigh, struct nl_addr *addr) in rtnl_neigh_set_lladdr() argument
999 __assign_addr(neigh, &neigh->n_lladdr, addr, NEIGH_ATTR_LLADDR, 1); in rtnl_neigh_set_lladdr()
1002 struct nl_addr *rtnl_neigh_get_lladdr(struct rtnl_neigh *neigh) in rtnl_neigh_get_lladdr() argument
1004 if (neigh->ce_mask & NEIGH_ATTR_LLADDR) in rtnl_neigh_get_lladdr()
1005 return neigh->n_lladdr; in rtnl_neigh_get_lladdr()
1010 int rtnl_neigh_set_dst(struct rtnl_neigh *neigh, struct nl_addr *addr) in rtnl_neigh_set_dst() argument
1012 return __assign_addr(neigh, &neigh->n_dst, addr, in rtnl_neigh_set_dst()
1016 struct nl_addr *rtnl_neigh_get_dst(struct rtnl_neigh *neigh) in rtnl_neigh_get_dst() argument
1018 if (neigh->ce_mask & NEIGH_ATTR_DST) in rtnl_neigh_get_dst()
1019 return neigh->n_dst; in rtnl_neigh_get_dst()
1024 void rtnl_neigh_set_family(struct rtnl_neigh *neigh, int family) in rtnl_neigh_set_family() argument
1026 neigh->n_family = family; in rtnl_neigh_set_family()
1027 neigh->ce_mask |= NEIGH_ATTR_FAMILY; in rtnl_neigh_set_family()
1030 int rtnl_neigh_get_family(struct rtnl_neigh *neigh) in rtnl_neigh_get_family() argument
1032 return neigh->n_family; in rtnl_neigh_get_family()
1035 void rtnl_neigh_set_type(struct rtnl_neigh *neigh, int type) in rtnl_neigh_set_type() argument
1037 neigh->n_type = type; in rtnl_neigh_set_type()
1038 neigh->ce_mask = NEIGH_ATTR_TYPE; in rtnl_neigh_set_type()
1041 int rtnl_neigh_get_type(struct rtnl_neigh *neigh) in rtnl_neigh_get_type() argument
1043 if (neigh->ce_mask & NEIGH_ATTR_TYPE) in rtnl_neigh_get_type()
1044 return neigh->n_type; in rtnl_neigh_get_type()
1049 void rtnl_neigh_set_vlan(struct rtnl_neigh *neigh, int vlan) in rtnl_neigh_set_vlan() argument
1051 neigh->n_vlan = vlan; in rtnl_neigh_set_vlan()
1052 neigh->ce_mask |= NEIGH_ATTR_VLAN; in rtnl_neigh_set_vlan()
1055 int rtnl_neigh_get_vlan(struct rtnl_neigh *neigh) in rtnl_neigh_get_vlan() argument
1057 if (neigh->ce_mask & NEIGH_ATTR_VLAN) in rtnl_neigh_get_vlan()
1058 return neigh->n_vlan; in rtnl_neigh_get_vlan()
1063 void rtnl_neigh_set_master(struct rtnl_neigh *neigh, int ifindex) in rtnl_neigh_set_master() argument
1065 neigh->n_master = ifindex; in rtnl_neigh_set_master()
1066 neigh->ce_mask |= NEIGH_ATTR_MASTER; in rtnl_neigh_set_master()
1069 int rtnl_neigh_get_master(struct rtnl_neigh *neigh) { in rtnl_neigh_get_master() argument
1070 return neigh->n_master; in rtnl_neigh_get_master()