Lines Matching refs:neigh
174 struct rtnl_neigh *neigh = nl_object_priv(c); in neigh_free_data() local
176 if (!neigh) in neigh_free_data()
179 nl_addr_put(neigh->n_lladdr); in neigh_free_data()
180 nl_addr_put(neigh->n_dst); in neigh_free_data()
255 struct rtnl_neigh *neigh; in neigh_msg_parser() local
260 neigh = rtnl_neigh_alloc(); in neigh_msg_parser()
261 if (!neigh) { in neigh_msg_parser()
266 neigh->ce_msgtype = n->nlmsg_type; in neigh_msg_parser()
273 neigh->n_family = nm->ndm_family; in neigh_msg_parser()
274 neigh->n_ifindex = nm->ndm_ifindex; in neigh_msg_parser()
275 neigh->n_state = nm->ndm_state; in neigh_msg_parser()
276 neigh->n_flags = nm->ndm_flags; in neigh_msg_parser()
277 neigh->n_type = nm->ndm_type; in neigh_msg_parser()
279 neigh->ce_mask |= (NEIGH_ATTR_FAMILY | NEIGH_ATTR_IFINDEX | in neigh_msg_parser()
284 neigh->n_lladdr = nl_addr_alloc_attr(tb[NDA_LLADDR], AF_UNSPEC); in neigh_msg_parser()
285 if (!neigh->n_lladdr) { in neigh_msg_parser()
289 nl_addr_set_family(neigh->n_lladdr, in neigh_msg_parser()
290 nl_addr_guess_family(neigh->n_lladdr)); in neigh_msg_parser()
291 neigh->ce_mask |= NEIGH_ATTR_LLADDR; in neigh_msg_parser()
295 neigh->n_dst = nl_addr_alloc_attr(tb[NDA_DST], neigh->n_family); in neigh_msg_parser()
296 if (!neigh->n_dst) { in neigh_msg_parser()
300 neigh->ce_mask |= NEIGH_ATTR_DST; in neigh_msg_parser()
306 neigh->n_cacheinfo.nci_confirmed = ci->ndm_confirmed; in neigh_msg_parser()
307 neigh->n_cacheinfo.nci_used = ci->ndm_used; in neigh_msg_parser()
308 neigh->n_cacheinfo.nci_updated = ci->ndm_updated; in neigh_msg_parser()
309 neigh->n_cacheinfo.nci_refcnt = ci->ndm_refcnt; in neigh_msg_parser()
311 neigh->ce_mask |= NEIGH_ATTR_CACHEINFO; in neigh_msg_parser()
315 neigh->n_probes = nla_get_u32(tb[NDA_PROBES]); in neigh_msg_parser()
316 neigh->ce_mask |= NEIGH_ATTR_PROBES; in neigh_msg_parser()
319 err = pp->pp_cb((struct nl_object *) neigh, pp); in neigh_msg_parser()
321 rtnl_neigh_put(neigh); in neigh_msg_parser()
388 struct rtnl_neigh *neigh = (struct rtnl_neigh *) obj; in neigh_dump_env() local
392 nl_af2str(neigh->n_family, buf, sizeof(buf))); in neigh_dump_env()
394 if (neigh->ce_mask & NEIGH_ATTR_LLADDR) in neigh_dump_env()
396 nl_addr2str(neigh->n_lladdr, buf, sizeof(buf))); in neigh_dump_env()
398 if (neigh->ce_mask & NEIGH_ATTR_DST) in neigh_dump_env()
400 nl_addr2str(neigh->n_dst, buf, sizeof(buf))); in neigh_dump_env()
402 if (neigh->ce_mask & NEIGH_ATTR_IFINDEX) { in neigh_dump_env()
405 nl_dump_line(p, "NEIGH_IFINDEX=%u\n", neigh->n_ifindex); in neigh_dump_env()
411 neigh->n_ifindex, in neigh_dump_env()
415 if (neigh->ce_mask & NEIGH_ATTR_PROBES) in neigh_dump_env()
416 nl_dump_line(p, "NEIGH_PROBES=%u\n", neigh->n_probes); in neigh_dump_env()
418 if (neigh->ce_mask & NEIGH_ATTR_TYPE) in neigh_dump_env()
420 nl_rtntype2str(neigh->n_type, buf, sizeof(buf))); in neigh_dump_env()
422 rtnl_neigh_flags2str(neigh->n_flags, buf, sizeof(buf)); in neigh_dump_env()
426 rtnl_neigh_state2str(neigh->n_state, buf, sizeof(buf)); in neigh_dump_env()
441 void rtnl_neigh_put(struct rtnl_neigh *neigh) in rtnl_neigh_put() argument
443 nl_object_put((struct nl_object *) neigh); in rtnl_neigh_put()
478 struct rtnl_neigh *neigh; in rtnl_neigh_get() local
480 nl_list_for_each_entry(neigh, &cache->c_items, ce_list) { in rtnl_neigh_get()
481 if (neigh->n_ifindex == ifindex && in rtnl_neigh_get()
482 !nl_addr_cmp(neigh->n_dst, dst)) { in rtnl_neigh_get()
483 nl_object_get((struct nl_object *) neigh); in rtnl_neigh_get()
484 return neigh; in rtnl_neigh_get()
616 int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags, in rtnl_neigh_build_delete_request() argument
619 return build_neigh_msg(neigh, RTM_DELNEIGH, flags, result); in rtnl_neigh_build_delete_request()
634 int rtnl_neigh_delete(struct nl_sock *sk, struct rtnl_neigh *neigh, in rtnl_neigh_delete() argument
640 if ((err = rtnl_neigh_build_delete_request(neigh, flags, &msg)) < 0) in rtnl_neigh_delete()
710 void rtnl_neigh_set_state(struct rtnl_neigh *neigh, int state) in rtnl_neigh_set_state() argument
712 neigh->n_state_mask |= state; in rtnl_neigh_set_state()
713 neigh->n_state |= state; in rtnl_neigh_set_state()
714 neigh->ce_mask |= NEIGH_ATTR_STATE; in rtnl_neigh_set_state()
717 int rtnl_neigh_get_state(struct rtnl_neigh *neigh) in rtnl_neigh_get_state() argument
719 if (neigh->ce_mask & NEIGH_ATTR_STATE) in rtnl_neigh_get_state()
720 return neigh->n_state; in rtnl_neigh_get_state()
725 void rtnl_neigh_unset_state(struct rtnl_neigh *neigh, int state) in rtnl_neigh_unset_state() argument
727 neigh->n_state_mask |= state; in rtnl_neigh_unset_state()
728 neigh->n_state &= ~state; in rtnl_neigh_unset_state()
729 neigh->ce_mask |= NEIGH_ATTR_STATE; in rtnl_neigh_unset_state()
732 void rtnl_neigh_set_flags(struct rtnl_neigh *neigh, unsigned int flags) in rtnl_neigh_set_flags() argument
734 neigh->n_flag_mask |= flags; in rtnl_neigh_set_flags()
735 neigh->n_flags |= flags; in rtnl_neigh_set_flags()
736 neigh->ce_mask |= NEIGH_ATTR_FLAGS; in rtnl_neigh_set_flags()
739 unsigned int rtnl_neigh_get_flags(struct rtnl_neigh *neigh) in rtnl_neigh_get_flags() argument
741 return neigh->n_flags; in rtnl_neigh_get_flags()
744 void rtnl_neigh_unset_flags(struct rtnl_neigh *neigh, unsigned int flags) in rtnl_neigh_unset_flags() argument
746 neigh->n_flag_mask |= flags; in rtnl_neigh_unset_flags()
747 neigh->n_flags &= ~flags; in rtnl_neigh_unset_flags()
748 neigh->ce_mask |= NEIGH_ATTR_FLAGS; in rtnl_neigh_unset_flags()
751 void rtnl_neigh_set_ifindex(struct rtnl_neigh *neigh, int ifindex) in rtnl_neigh_set_ifindex() argument
753 neigh->n_ifindex = ifindex; in rtnl_neigh_set_ifindex()
754 neigh->ce_mask |= NEIGH_ATTR_IFINDEX; in rtnl_neigh_set_ifindex()
757 int rtnl_neigh_get_ifindex(struct rtnl_neigh *neigh) in rtnl_neigh_get_ifindex() argument
759 return neigh->n_ifindex; in rtnl_neigh_get_ifindex()
762 static inline int __assign_addr(struct rtnl_neigh *neigh, struct nl_addr **pos, in __assign_addr() argument
766 if (neigh->ce_mask & NEIGH_ATTR_FAMILY) { in __assign_addr()
767 if (new->a_family != neigh->n_family) in __assign_addr()
770 neigh->n_family = new->a_family; in __assign_addr()
771 neigh->ce_mask |= NEIGH_ATTR_FAMILY; in __assign_addr()
781 neigh->ce_mask |= flag; in __assign_addr()
786 void rtnl_neigh_set_lladdr(struct rtnl_neigh *neigh, struct nl_addr *addr) in rtnl_neigh_set_lladdr() argument
788 __assign_addr(neigh, &neigh->n_lladdr, addr, NEIGH_ATTR_LLADDR, 1); in rtnl_neigh_set_lladdr()
791 struct nl_addr *rtnl_neigh_get_lladdr(struct rtnl_neigh *neigh) in rtnl_neigh_get_lladdr() argument
793 if (neigh->ce_mask & NEIGH_ATTR_LLADDR) in rtnl_neigh_get_lladdr()
794 return neigh->n_lladdr; in rtnl_neigh_get_lladdr()
799 int rtnl_neigh_set_dst(struct rtnl_neigh *neigh, struct nl_addr *addr) in rtnl_neigh_set_dst() argument
801 return __assign_addr(neigh, &neigh->n_dst, addr, in rtnl_neigh_set_dst()
805 struct nl_addr *rtnl_neigh_get_dst(struct rtnl_neigh *neigh) in rtnl_neigh_get_dst() argument
807 if (neigh->ce_mask & NEIGH_ATTR_DST) in rtnl_neigh_get_dst()
808 return neigh->n_dst; in rtnl_neigh_get_dst()
813 void rtnl_neigh_set_family(struct rtnl_neigh *neigh, int family) in rtnl_neigh_set_family() argument
815 neigh->n_family = family; in rtnl_neigh_set_family()
816 neigh->ce_mask |= NEIGH_ATTR_FAMILY; in rtnl_neigh_set_family()
819 int rtnl_neigh_get_family(struct rtnl_neigh *neigh) in rtnl_neigh_get_family() argument
821 return neigh->n_family; in rtnl_neigh_get_family()
824 void rtnl_neigh_set_type(struct rtnl_neigh *neigh, int type) in rtnl_neigh_set_type() argument
826 neigh->n_type = type; in rtnl_neigh_set_type()
827 neigh->ce_mask = NEIGH_ATTR_TYPE; in rtnl_neigh_set_type()
830 int rtnl_neigh_get_type(struct rtnl_neigh *neigh) in rtnl_neigh_get_type() argument
832 if (neigh->ce_mask & NEIGH_ATTR_TYPE) in rtnl_neigh_get_type()
833 return neigh->n_type; in rtnl_neigh_get_type()