netlink: use ifmedia to provide vlan interface operstate.

Netlink customers rely on admin and operational state when
 working with interfaces. The current implementation retuns
 "unknown" operstate for all interface types except IFT_ETHER
 and IFT_LOOP.

This change updates the code to fetch vlan operstate in the same way
 as for the ether interfaces. For the rest of the interface types,
 operstate is now mapped to the admin state.

Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after:	3 days
This commit is contained in:
Alexander V. Chernikov 2023-02-15 20:22:47 +00:00
parent 5f044c4e05
commit 5dd48f7184

View File

@ -174,9 +174,11 @@ get_operstate(struct ifnet *ifp, struct if_state *pstate)
switch (ifp->if_type) {
case IFT_ETHER:
case IFT_L2VLAN:
get_operstate_ether(ifp, pstate);
break;
case IFT_LOOP:
default:
/* Map admin state to the operstate */
if (ifp->if_flags & IFF_UP) {
pstate->ifla_operstate = IF_OPER_UP;
pstate->ifla_carrier = 1;