https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L64.

    Positional arguments:
    family -- genl_family class instance.
    grp_attr -- nlattr class instance.

    Returns:
    0 on success or a negative error code.

def parse_mcast_grps(family, grp_attr):
    """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L64.

    Positional arguments:
    family -- genl_family class instance.
    grp_attr -- nlattr class instance.

    Returns:
    0 on success or a negative error code.
    """
    remaining = c_int()
    if not grp_attr:
        raise BUG

    for nla in nla_for_each_nested(grp_attr, remaining):
        tb = dict()
        err = nla_parse_nested(tb, CTRL_ATTR_MCAST_GRP_MAX, nla, family_grp_policy)
        if err < 0:
            return err
        if not tb[CTRL_ATTR_MCAST_GRP_ID] or not tb[CTRL_ATTR_MCAST_GRP_NAME]:
            return -NLE_MISSING_ATTR

        id_ = nla_get_u32(tb[CTRL_ATTR_MCAST_GRP_ID])
        name = nla_get_string(tb[CTRL_ATTR_MCAST_GRP_NAME])

        err = genl_family_add_grp(family, id_, name)
        if err < 0:
            return err

    return 0