netlink: fix vlan interface creation

MFC after:	2 weeks
This commit is contained in:
Alexander V. Chernikov 2023-03-03 16:01:34 +00:00
parent 61507ae30b
commit ce9f95bd83
2 changed files with 19 additions and 16 deletions

View File

@ -144,20 +144,14 @@ store_cookie(struct nl_pstate *npt, struct ifnet *ifp)
nlmsg_report_cookie(npt, nla_cookie);
}
/*
* Generic creation interface handler.
* Responsible for creating interfaces w/o parameters and setting
* misc attributes such as state, mtu or description.
*/
static int
create_generic(struct nl_parsed_link *lattrs, const struct nlattr_bmask *bm,
struct nlpcb *nlp, struct nl_pstate *npt)
create_generic_ifd(struct nl_parsed_link *lattrs, const struct nlattr_bmask *bm,
struct ifc_data *ifd, struct nlpcb *nlp, struct nl_pstate *npt)
{
int error = 0;
struct ifc_data ifd = {};
struct ifnet *ifp = NULL;
error = ifc_create_ifp(lattrs->ifla_ifname, &ifd, &ifp);
error = ifc_create_ifp(lattrs->ifla_ifname, ifd, &ifp);
NLP_LOG(LOG_DEBUG2, nlp, "clone for %s returned %d", lattrs->ifla_ifname, error);
@ -177,6 +171,19 @@ create_generic(struct nl_parsed_link *lattrs, const struct nlattr_bmask *bm,
return (error);
}
/*
* Generic creation interface handler.
* Responsible for creating interfaces w/o parameters and setting
* misc attributes such as state, mtu or description.
*/
static int
create_generic(struct nl_parsed_link *lattrs, const struct nlattr_bmask *bm,
struct nlpcb *nlp, struct nl_pstate *npt)
{
struct ifc_data ifd = {};
return (create_generic_ifd(lattrs, bm, &ifd, nlp, npt));
}
struct nl_cloner generic_cloner = {
.name = "_default_",
@ -258,17 +265,14 @@ create_vlan(struct nl_parsed_link *lattrs, const struct nlattr_bmask *bm,
return (ENOENT);
}
/* Waiting till if_clone changes lands */
/*
struct vlanreq params = {
.vlr_tag = attrs.vlan_id,
.vlr_proto = attrs.vlan_proto,
};
*/
int ifname_len = strlen(lattrs->ifla_ifname) + 1;
error = if_clone_create(lattrs->ifla_ifname, ifname_len, (char *)NULL);
strlcpy(params.vlr_parent, if_name(ifp), sizeof(params.vlr_parent));
struct ifc_data ifd = { .flags = IFC_F_SYSSPACE, .params = &params };
NLP_LOG(LOG_DEBUG2, nlp, "clone for %s returned %d", lattrs->ifla_ifname, error);
error = create_generic_ifd(lattrs, bm, &ifd, nlp, npt);
if_rele(ifp);
return (error);

View File

@ -313,7 +313,6 @@ def test_dump_ifaces_many(self):
# * {{nla_len=8, nla_type=IFLA_INFO_KIND}, "vlan"...},
# * {{nla_len=12, nla_type=IFLA_INFO_DATA}, "\x06\x00\x01\x00\x16\x00\x00\x00"}
# */
@pytest.mark.skip(reason="vlan support needs more work")
@pytest.mark.require_user("root")
def test_create_vlan_plain(self):
"""Creates 802.1Q VLAN interface in vlanXX and ifX fashion"""