Skip to contentSkip to conversation

How to assign sockaddr_nl->nl_groups when using connector

DISCUSSION vaughan 2 participants 2 messages Mar 19, 2013 – Mar 20, 2013

Subsystems (2)
lore
Share & tools
lore

vaughan

author
#0 lore raw

Hi Evgeniy,

I am not quite sure how to assign nl_groups when using connector. You Documentation/connector/connector.txt don't explain it very clearly. I thought it's a bitmask representing only 32 groups.
If I just want to subscribe only one group such as CN_KVP_IDX, what shall I do? Which one below is correct?
a) l_local.nl_groups = CN_KVP_IDX;
Or
b) l_local.nl_groups = 1 << (CN_KVP_IDX -1)
and bind with bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)).
I ran your example in Documentation/connector/. 'l_local.nl_groups = -1' in ucon.c seems subscribe all channels, because if I start cgred service, ucon will receive messages with idx=1.

And it seems setsockopt is not needed now, for it is done by netlink_autobind? You even comment it out using '#if 0' in Documentation/connector/ucon.c.

Could you do me a favor to check
http://driverdev.linuxdriverproject.org/pipermail/devel/2013-March/036306.html
to see if my understanding is correct or not? Thanks.

Signature · 2 lines
Regards,
Vaughan
#1 lore raw

Hi

Quoted 10 lines · vaughan

I am not quite sure how to assign nl_groups when using connector. You Documentation/connector/connector.txt don't explain it very clearly. I thought it's a bitmask representing only 32 groups.
If I just want to subscribe only one group such as CN_KVP_IDX, what shall I do? Which one below is correct?
a) l_local.nl_groups = CN_KVP_IDX;
Or
b) l_local.nl_groups = 1 << (CN_KVP_IDX -1)
and bind with bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)).

Iirc, first groups, created before bitmap-to-number conversion were actually bitmaps, but then broadcast interface was obsoleted.

One should use NETLINK_ADD_MEMBERSHIP interface and specify gruop number directly.

Quoted 11 lines

I ran your example in Documentation/connector/. 'l_local.nl_groups = -1' in ucon.c seems subscribe all channels, because if I start cgred service, ucon will receive messages with idx=1.

And it seems setsockopt is not needed now, for it is done by netlink_autobind? You even comment it out using '#if 0' in Documentation/connector/ucon.c.

Could you do me a favor to check
http://driverdev.linuxdriverproject.org/pipermail/devel/2013-March/036306.html
to see if my understanding is correct or not? Thanks.

Yes, you are right.

Signature · 1 line
	Evgeniy Polyakov