Ask for link and address data on the same socket.

Thomas Graf tgraf at suug.ch
Thu Jul 11 15:32:35 EDT 2013


On 07/10/13 at 03:48pm, Tilman Baumann wrote:
> On 04/07/13 20:55, Thomas Graf wrote:
> > On 07/04/13 at 02:56pm, Tilman Baumann wrote:
> >> Hi,
> >>
> >> I have a receive function that reads RTM_NEWADDR and RTM_NEWLINK messages.
> >>
> >> But my code for sending the request is buggered.
> >>
> >> I must be doing the chaining of netlink messages wrong.
> >> The RTM_GETLINK part seems to be ignored. I never receive the response
> >> to that.
> >>
> >> My kernel is really old, 2.6.18 plus some montavista patches. (Running
> >> on arm)
> >> But it probably has to do with the way I send the request.
> >>
> >> How should it be done?
> >>
> >> Thank you very much for your help.
> >> I started that code a long time ago, but left the macaddress stuff
> >> broken so far, but now I need it and I don't even remember if I was sure
> >> the way I coded it way back made any sense. :-/
> >>
> >>
> 
> > NLMSG_DONE is not a flag but a message type. You would need to
> > send it as a separate message to end the multi message stream.
> > You can find additional information on this in the libnl guide.
> >
> > However, I suggest you send each request separately to ease
> > parsing of the response.
> >
> >
> The parse part can deal with both types of responses very well.
> Do you mean I should send the requests individually via send() and with
> NLMSG_DONE?
> Or assemble the request chain how I did with NLMSG_NEXT() and a empty or
> rtgenmsg request with NLMSG_DONE at the end?

The kernel is not ready to handle that.

I suggest that you use individual send() calls to send the RTM_GETADDR
and RTM_GETLINK requests so you don't need to send a NLMSG_DONE
message at all.



More information about the libnl mailing list