Changeset View
Changeset View
Standalone View
Standalone View
sys/netlink/route/iface_drivers.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | _nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs, | ||||
if (lattrs->ifla_ifalias != NULL) { | if (lattrs->ifla_ifalias != NULL) { | ||||
if (nlp_has_priv(npt->nlp, PRIV_NET_SETIFDESCR)) { | if (nlp_has_priv(npt->nlp, PRIV_NET_SETIFDESCR)) { | ||||
int len = strlen(lattrs->ifla_ifalias) + 1; | int len = strlen(lattrs->ifla_ifalias) + 1; | ||||
char *buf = if_allocdescr(len, M_WAITOK); | char *buf = if_allocdescr(len, M_WAITOK); | ||||
memcpy(buf, lattrs->ifla_ifalias, len); | memcpy(buf, lattrs->ifla_ifalias, len); | ||||
if_setdescr(ifp, buf); | if_setdescr(ifp, buf); | ||||
getmicrotime(&ifp->if_lastchange); | if_setlastchange(ifp); | ||||
} else { | } else { | ||||
nlmsg_report_err_msg(npt, "Not enough privileges to set descr"); | nlmsg_report_err_msg(npt, "Not enough privileges to set descr"); | ||||
return (EPERM); | return (EPERM); | ||||
} | } | ||||
} | } | ||||
if ((lattrs->ifi_change & IFF_UP) && (lattrs->ifi_flags & IFF_UP) == 0) { | if ((lattrs->ifi_change & IFF_UP) && (lattrs->ifi_flags & IFF_UP) == 0) { | ||||
/* Request to down the interface */ | /* Request to down the interface */ | ||||
Show All 28 Lines | |||||
* NLMSGERR_ATTR_COOKIE(nested) | * NLMSGERR_ATTR_COOKIE(nested) | ||||
* IFLA_NEW_IFINDEX(u32) | * IFLA_NEW_IFINDEX(u32) | ||||
* IFLA_IFNAME(string) | * IFLA_IFNAME(string) | ||||
*/ | */ | ||||
void | void | ||||
_nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp) | _nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp) | ||||
{ | { | ||||
int ifname_len = strlen(if_name(ifp)); | int ifname_len = strlen(if_name(ifp)); | ||||
uint32_t ifindex = (uint32_t)ifp->if_index; | uint32_t ifindex = (uint32_t)if_getindex(ifp); | ||||
int nla_len = sizeof(struct nlattr) * 3 + | int nla_len = sizeof(struct nlattr) * 3 + | ||||
sizeof(ifindex) + NL_ITEM_ALIGN(ifname_len + 1); | sizeof(ifindex) + NL_ITEM_ALIGN(ifname_len + 1); | ||||
struct nlattr *nla_cookie = npt_alloc(npt, nla_len); | struct nlattr *nla_cookie = npt_alloc(npt, nla_len); | ||||
/* Nested TLV */ | /* Nested TLV */ | ||||
nla_cookie->nla_len = nla_len; | nla_cookie->nla_len = nla_len; | ||||
nla_cookie->nla_type = NLMSGERR_ATTR_COOKIE; | nla_cookie->nla_type = NLMSGERR_ATTR_COOKIE; | ||||
Show All 14 Lines |