generic netlink question with multicast group

Stig Thormodsrud stig at ubnt.com
Wed Mar 18 16:59:38 PDT 2015


Hi,

I'm using debian libnl 3.2.7-4 for mips with linux 3.10.20 and trying
to use a mulitcast group to export data from a kernel module to a
user-space app.  I've looked a bunch of examples and my user-space
start-up looks like:

    sock = nl_socket_alloc();
    nl_socket_disable_seq_check(sock);
    rc = genl_connect(sock);
    if (rc != 0) {
        printf("failed to connect %d\n", rc);
        exit(1);
    }
    family = genl_ctrl_resolve(sock, EXPORT_FAMILY);
    if (family < 0) {
        printf("failed to find family %d\n", family);
        exit(1);
    }
    group = genl_ctrl_resolve_grp(sock, EXPORT_FAMILY, EXPORT_MC_GROUP);
    if (group < 0) {
        printf("failed to find group %d\n", group);
        exit(1);
    }
    rc = nl_socket_add_memberships(sock, family, group);
    if (rc < 0) {
        printf("failed to add membership %d\n", rc);
        exit(1);
    }
    nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL);


If I use this as is the nl_socket_add_memberships() fails with invalid
argument.  So to debug it I added a printf with the family/group and
then it's able to add the membership and receive my netlink messages.

Any idea why the printf delay (or maybe context switch) would be
required for the add_membership to work?

stig



More information about the libnl mailing list