dev_add_pack and protocol handlers

From: Krzysztof Halasa (khc@intrepid.pm.waw.pl)
Date: Sun May 28 2000 - 17:51:02 EST


Hi,

Just some questions about net/core/dev.c.

dev_add_pack(struct packet_type *) registers protocol handler.
The handler is then:
   int func (struct sk_buff *, struct net_device *, struct packet_type *);

Why does it return "int" and not "void"? All functions, including
net_rx_action, ignore its return value.

How to use the handler efficiently? I need to extract IP/IPv6/etc packets
from HDLC/FR/etc frames. I use dev_add_pack to register a handler,
but what should I do after I strip link level header from skb?

Say, I have:

int HDLC_proto_rcv(skb, dev, packet_type)
{
        various_tests();
        skb_pull(skb, xxx);
        skb->protocol = ETH_P_IP; /* or IPv6, IPX, etc */

        Now, I want this frame reexamined and passed to IP/etc protocol
        handler. How?

I think it should be best to just return it to net_rx_action, which should
then reiterate through ptype_base[] and call higher level protocol handler.

In such case, rcv's return value of 0 could mean that the packet has been
accepted, and non-zero would mean it has been processed, lower level
info has been stripped and it should be resent to protocol handler(s).

Of course, ptype_all (taps) should only be called once.

Any ideas?

I can write a patch, of course.

-- 
Krzysztof Halasa
Network Administrator

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:20 EST