Lines Matching refs:mvi
66 struct macvlan_info *mvi; in macvlan_alloc() local
70 mvi = link->l_info; in macvlan_alloc()
71 for (i = 0; i < mvi->mvi_maccount; i++) in macvlan_alloc()
72 nl_addr_put(mvi->mvi_macaddr[i]); in macvlan_alloc()
73 free(mvi->mvi_macaddr); in macvlan_alloc()
74 memset(mvi, 0, sizeof(*mvi)); in macvlan_alloc()
76 if ((mvi = calloc(1, sizeof(*mvi))) == NULL) in macvlan_alloc()
79 link->l_info = mvi; in macvlan_alloc()
81 mvi->mvi_macmode = MACVLAN_MACADDR_SET; in macvlan_alloc()
90 struct macvlan_info *mvi; in macvlan_parse() local
103 mvi = link->l_info; in macvlan_parse()
106 mvi->mvi_mode = nla_get_u32(tb[IFLA_MACVLAN_MODE]); in macvlan_parse()
107 mvi->mvi_mask |= MACVLAN_HAS_MODE; in macvlan_parse()
111 mvi->mvi_flags = nla_get_u16(tb[IFLA_MACVLAN_FLAGS]); in macvlan_parse()
112 mvi->mvi_mask |= MACVLAN_HAS_FLAGS; in macvlan_parse()
117 mvi->mvi_maccount = nla_get_u32(tb[IFLA_MACVLAN_MACADDR_COUNT]); in macvlan_parse()
118 if (mvi->mvi_maccount > 0) { in macvlan_parse()
124 mvi->mvi_macaddr = calloc(mvi->mvi_maccount, in macvlan_parse()
125 sizeof(*(mvi->mvi_macaddr))); in macvlan_parse()
129 if (i >= mvi->mvi_maccount) in macvlan_parse()
134 mvi->mvi_macaddr[i] = nl_addr_alloc_attr(nla, AF_LLC); in macvlan_parse()
138 mvi->mvi_mask |= MACVLAN_HAS_MACADDR; in macvlan_parse()
148 struct macvlan_info *mvi; in macvlan_free() local
151 mvi = link->l_info; in macvlan_free()
153 for (i = 0; i < mvi->mvi_maccount; i++) in macvlan_free()
154 nl_addr_put(mvi->mvi_macaddr[i]); in macvlan_free()
155 free(mvi->mvi_macaddr); in macvlan_free()
156 free(mvi); in macvlan_free()
165 struct macvlan_info *mvi = link->l_info; in macvlan_dump_details() local
167 if (mvi->mvi_mask & MACVLAN_HAS_MODE) { in macvlan_dump_details()
168 rtnl_link_macvlan_mode2str(mvi->mvi_mode, buf, sizeof(buf)); in macvlan_dump_details()
172 if (mvi->mvi_mask & MACVLAN_HAS_FLAGS) { in macvlan_dump_details()
173 rtnl_link_macvlan_flags2str(mvi->mvi_flags, buf, sizeof(buf)); in macvlan_dump_details()
177 if (mvi->mvi_mask & MACVLAN_HAS_MACADDR) { in macvlan_dump_details()
178 nl_dump(p, " macvlan-count %u", (unsigned) mvi->mvi_maccount); in macvlan_dump_details()
180 if (mvi->mvi_maccount) in macvlan_dump_details()
183 for (i = 0; i < mvi->mvi_maccount; i++) { in macvlan_dump_details()
184 nl_dump(p, " %s", nl_addr2str(mvi->mvi_macaddr[i], buf, in macvlan_dump_details()
221 struct macvlan_info *mvi = link->l_info; in macvlan_put_attrs() local
230 if (mvi->mvi_mask & MACVLAN_HAS_MODE) in macvlan_put_attrs()
231 NLA_PUT_U32(msg, IFLA_MACVLAN_MODE, mvi->mvi_mode); in macvlan_put_attrs()
233 if (mvi->mvi_mask & MACVLAN_HAS_FLAGS) in macvlan_put_attrs()
234 NLA_PUT_U16(msg, IFLA_MACVLAN_FLAGS, mvi->mvi_flags); in macvlan_put_attrs()
236 if (mvi->mvi_mask & MACVLAN_HAS_MACADDR) { in macvlan_put_attrs()
237 NLA_PUT_U32(msg, IFLA_MACVLAN_MACADDR_MODE, mvi->mvi_macmode); in macvlan_put_attrs()
242 for (i = 0; i < mvi->mvi_maccount; i++) { in macvlan_put_attrs()
244 mvi->mvi_macaddr[i]); in macvlan_put_attrs()
343 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_set_mode() local
348 mvi->mvi_mode = mode; in rtnl_link_macvlan_set_mode()
349 mvi->mvi_mask |= MACVLAN_HAS_MODE; in rtnl_link_macvlan_set_mode()
352 for (i = 0; i < mvi->mvi_maccount; i++) in rtnl_link_macvlan_set_mode()
353 nl_addr_put(mvi->mvi_macaddr[i]); in rtnl_link_macvlan_set_mode()
354 free(mvi->mvi_macaddr); in rtnl_link_macvlan_set_mode()
355 mvi->mvi_maccount = 0; in rtnl_link_macvlan_set_mode()
356 mvi->mvi_macaddr = NULL; in rtnl_link_macvlan_set_mode()
357 mvi->mvi_macmode = MACVLAN_MACADDR_SET; in rtnl_link_macvlan_set_mode()
358 mvi->mvi_mask &= ~MACVLAN_HAS_MACADDR; in rtnl_link_macvlan_set_mode()
372 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_get_mode() local
376 if (mvi->mvi_mask & MACVLAN_HAS_MODE) in rtnl_link_macvlan_get_mode()
377 return mvi->mvi_mode; in rtnl_link_macvlan_get_mode()
393 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_set_macmode() local
397 if (!(mvi->mvi_mask & MACVLAN_HAS_MODE) || in rtnl_link_macvlan_set_macmode()
398 (mvi->mvi_mode != MACVLAN_MODE_SOURCE)) in rtnl_link_macvlan_set_macmode()
401 mvi->mvi_macmode = macmode; in rtnl_link_macvlan_set_macmode()
402 mvi->mvi_mask |= MACVLAN_HAS_MACADDR; in rtnl_link_macvlan_set_macmode()
418 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_get_macmode() local
422 if (!(mvi->mvi_mask & MACVLAN_HAS_MODE) || in rtnl_link_macvlan_get_macmode()
423 (mvi->mvi_mode != MACVLAN_MODE_SOURCE)) in rtnl_link_macvlan_get_macmode()
426 if (!(mvi->mvi_mask & MACVLAN_HAS_MACADDR)) in rtnl_link_macvlan_get_macmode()
429 *out_macmode = mvi->mvi_macmode; in rtnl_link_macvlan_get_macmode()
443 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_set_flags() local
447 mvi->mvi_flags |= flags; in rtnl_link_macvlan_set_flags()
448 mvi->mvi_mask |= MACVLAN_HAS_FLAGS; in rtnl_link_macvlan_set_flags()
465 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_unset_flags() local
469 mvi->mvi_flags &= ~flags; in rtnl_link_macvlan_unset_flags()
470 mvi->mvi_mask |= MACVLAN_HAS_FLAGS; in rtnl_link_macvlan_unset_flags()
483 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_get_flags() local
487 return mvi->mvi_flags; in rtnl_link_macvlan_get_flags()
499 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_count_macaddr() local
503 if (!(mvi->mvi_mask & MACVLAN_HAS_MODE) || in rtnl_link_macvlan_count_macaddr()
504 (mvi->mvi_mode != MACVLAN_MODE_SOURCE)) in rtnl_link_macvlan_count_macaddr()
507 if (!(mvi->mvi_mask & MACVLAN_HAS_MACADDR)) in rtnl_link_macvlan_count_macaddr()
510 *out_count = mvi->mvi_maccount; in rtnl_link_macvlan_count_macaddr()
529 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_get_macaddr() local
533 if (!(mvi->mvi_mask & MACVLAN_HAS_MODE) || in rtnl_link_macvlan_get_macaddr()
534 (mvi->mvi_mode != MACVLAN_MODE_SOURCE)) in rtnl_link_macvlan_get_macaddr()
537 if (!(mvi->mvi_mask & MACVLAN_HAS_MACADDR)) in rtnl_link_macvlan_get_macaddr()
540 if (idx >= mvi->mvi_maccount) in rtnl_link_macvlan_get_macaddr()
543 *out_addr = mvi->mvi_macaddr[idx]; in rtnl_link_macvlan_get_macaddr()
558 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_add_macaddr() local
567 if (!(mvi->mvi_mask & MACVLAN_HAS_MODE) || in rtnl_link_macvlan_add_macaddr()
568 (mvi->mvi_mode != MACVLAN_MODE_SOURCE)) in rtnl_link_macvlan_add_macaddr()
571 if (!(mvi->mvi_mask & MACVLAN_HAS_MACADDR)) in rtnl_link_macvlan_add_macaddr()
574 if (mvi->mvi_maccount >= UINT32_MAX) in rtnl_link_macvlan_add_macaddr()
577 newsize = (mvi->mvi_maccount + 1) * sizeof(*(mvi->mvi_macaddr)); in rtnl_link_macvlan_add_macaddr()
578 mvi_macaddr = realloc(mvi->mvi_macaddr, newsize); in rtnl_link_macvlan_add_macaddr()
582 mvi->mvi_macaddr = mvi_macaddr; in rtnl_link_macvlan_add_macaddr()
583 mvi->mvi_macaddr[mvi->mvi_maccount] = nl_addr_clone(addr); in rtnl_link_macvlan_add_macaddr()
584 mvi->mvi_maccount++; in rtnl_link_macvlan_add_macaddr()
586 mvi->mvi_mask |= MACVLAN_HAS_MACADDR; in rtnl_link_macvlan_add_macaddr()
603 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvlan_del_macaddr() local
611 if (!(mvi->mvi_mask & MACVLAN_HAS_MODE) || in rtnl_link_macvlan_del_macaddr()
612 (mvi->mvi_mode != MACVLAN_MODE_SOURCE)) in rtnl_link_macvlan_del_macaddr()
615 if (!(mvi->mvi_mask & MACVLAN_HAS_MACADDR)) in rtnl_link_macvlan_del_macaddr()
621 while (i + found < mvi->mvi_maccount) { in rtnl_link_macvlan_del_macaddr()
622 mvi->mvi_macaddr[i] = mvi->mvi_macaddr[i + found]; in rtnl_link_macvlan_del_macaddr()
624 mvi->mvi_macaddr[i + found] = NULL; in rtnl_link_macvlan_del_macaddr()
625 if (nl_addr_cmp(addr, mvi->mvi_macaddr[i]) == 0) { in rtnl_link_macvlan_del_macaddr()
626 nl_addr_put(mvi->mvi_macaddr[i]); in rtnl_link_macvlan_del_macaddr()
627 mvi->mvi_macaddr[i] = NULL; in rtnl_link_macvlan_del_macaddr()
635 mvi->mvi_maccount -= found; in rtnl_link_macvlan_del_macaddr()
689 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvtap_set_mode() local
693 mvi->mvi_mode = mode; in rtnl_link_macvtap_set_mode()
694 mvi->mvi_mask |= MACVLAN_HAS_MODE; in rtnl_link_macvtap_set_mode()
707 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvtap_get_mode() local
711 if (mvi->mvi_mask & MACVLAN_HAS_MODE) in rtnl_link_macvtap_get_mode()
712 return mvi->mvi_mode; in rtnl_link_macvtap_get_mode()
726 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvtap_set_flags() local
730 mvi->mvi_flags |= flags; in rtnl_link_macvtap_set_flags()
731 mvi->mvi_mask |= MACVLAN_HAS_FLAGS; in rtnl_link_macvtap_set_flags()
748 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvtap_unset_flags() local
752 mvi->mvi_flags &= ~flags; in rtnl_link_macvtap_unset_flags()
753 mvi->mvi_mask |= MACVLAN_HAS_FLAGS; in rtnl_link_macvtap_unset_flags()
766 struct macvlan_info *mvi = link->l_info; in rtnl_link_macvtap_get_flags() local
770 return mvi->mvi_flags; in rtnl_link_macvtap_get_flags()