Sending an IP packet
Rami Rosen
roszenrami at gmail.com
Fri Feb 22 09:05:34 EST 2013
Hi, Adel,
ip_route_output_flow() calls
__ip_route_output_key().
The return value is the routing entry, rtable.
the parameters for __ip_route_output_key() do not
include sock; only net and flow (flp4).
And the __ip_route_output_key() is exported.
There is
a call for xfrm_lookup() which does need a sock
in ip_route_output_flow()
The xfrm_lookup() is empty when building without IPsec.
So in you case, if you know that your solution does not require
IPSec traffic, you can use __ip_route_output_key().
rgs.
Rami Rosen
http://ramirose.wix.com/ramirosen
On Fri, Feb 22, 2013 at 3:53 PM, Adel Qodmani <mpcadel at gmail.com> wrote:
> On Fri, Feb 22, 2013 at 3:47 PM, Rami Rosen <roszenrami at gmail.com> wrote:
>>
>> Hi, Adel,
>>
>> You should use
>> ip_route_output_flow().
>> For this you should construct a
>> flowi4 instance.
>> ip_route_output_flow() is exported via EXPORT_SYMBOL_GPL.
>>
>> See for example how this is done in udp_sendmsg().
>>
>> Good luck!
>>
>> Rami Rosen
>> http://ramirose.wix.com/ramirosen
>>
>> On Fri, Feb 22, 2013 at 2:36 PM, Adel Qodmani <mpcadel at gmail.com> wrote:
>> > Hey,
>> >
>> > My question is quite simple, I have an sk_buff that I want to transmit,
>> > the
>> > sk_buff is an ICMP message and so far, I've built the headers and set up
>> > everything.
>> >
>> > The problem is, when I want to do such a thing, I typically use a
>> > function
>> > called:
>> > dev_queue_xmit which takes the skb and transmits the packet using the
>> > net_device specified in the skb; but time time I can't set the
>> > net_device, I
>> > need the packet to go through the routing code and get it sent normally;
>> > so
>> > what function can I use to that?
>> >
>> > Some notes:
>> > *The kernel I am working on is 3.2.0-37
>> > *I am working using Modules, so symbols that are not exported are
>> > unreachable for me
>> > *I set the IP header using htons, so my header data is already in
>> > network
>> > byte-order.
>> >
>> > Regards,
>> > Adel
>> >
>> > _______________________________________________
>> > Kernelnewbies mailing list
>> > Kernelnewbies at kernelnewbies.org
>> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >
>
> Hi Rami,
>
> Using ip_route_output_flow() or using udp_sendmsg() would require not only
> constructing a flowi4 but also a sock; I am intentionally trying to avoid
> building a sock at the time being.
> Is there a way I can deliver my sk_buff to the routing code so that it'd set
> the net_device in there or at least tell me which interface to use and then
> I'd set it up myself?
>
> Thankful,
> Adel
More information about the Kernelnewbies
mailing list