All of lore.kernel.org
 help / color / mirror / Atom feed
* Packet forwarding using netfilter
@ 2007-05-31  3:15 Sarbeswar Mohapatra
  0 siblings, 0 replies; only message in thread
From: Sarbeswar Mohapatra @ 2007-05-31  3:15 UTC (permalink / raw)
  To: netfilter-devel

Hi,
Can anybody help me, how to forward the incoming packets to another machine
using PRE_ROUTING hook (case-1 through the same interface the packet came
in, case-2 through a different interface).
In case of case-2, I tried turning on the ip forwarding option in (echo 1 >
/proc/sys/net/ipv4/ip_forward), but no luck. Basically the packet probably
gets discarded in ip_receive_finish function, but not sure.

Here is the sample code, where after receiveing the packet in the hook, the
ip address is changed (skb->nh.ip->saddr = xxx, skb->nh.ip->daddr = yyyy)
and the route is updated,
     struct flowi fl;

     fl.nl_u.ip4_u.daddr = xxx;
     fl.nl_u.ip4_u.saddr = yyy;
     fl.nl_u.ip4_u.tos = 5;

    (*skb)->nfcache |= NFC_IP_SRC;
    (*skb)->nfcache |= NFC_IP_DST;
    (*skb)->nfcache |= NFC_ALTERED;

    if (ip_route_output_key(&rt, &fl) < 0)
    {
        printk("No output route ...\n");
        return -1;
    }
    else
    {
        if ((*skb)->dst)
            dst_release((*skb)->dst);
        (*skb)->dst = dst_clone(&rt->u.dst);
        (*skb)->dev = rt->u.dst.dev;
        ip_rt_put(rt);
    }

Regards,
Sarbeswar

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-31  3:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-31  3:15 Packet forwarding using netfilter Sarbeswar Mohapatra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.