From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: David Howells <dhowells@redhat.com>
Cc: netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: Re: How to find I/F to destination
Date: Fri, 4 May 2007 16:54:38 +0400 [thread overview]
Message-ID: <20070504125438.GA5439@2ka.mipt.ru> (raw)
In-Reply-To: <5484.1178282928@redhat.com>
On Fri, May 04, 2007 at 01:48:48PM +0100, David Howells (dhowells@redhat.com) wrote:
>
> Hi,
Hi David.
> I would like to determine through which interface packets sent to a particular
> UDP destination will go through, and so determine the MTU size for that
> interface. Can anyone suggest a good way of doing this from within the
> kernel?
I used following code in netchannels:
static int netchannel_ip_route_output_flow(struct rtable **rp, struct flowi *flp, int flags)
{
int err;
err = __ip_route_output_key(rp, flp);
if (err)
return err;
if (flp->proto) {
if (!flp->fl4_src)
flp->fl4_src = (*rp)->rt_src;
if (!flp->fl4_dst)
flp->fl4_dst = (*rp)->rt_dst;
}
return 0;
}
struct dst_entry *route_get_raw(u32 saddr, u32 daddr, u16 sport, u16 dport, u8 proto)
{
struct rtable *rt;
struct flowi fl = { .oif = 0,
.nl_u = { .ip4_u =
{ .saddr = saddr,
.daddr = daddr,
.tos = 0 } },
.proto = proto,
.uli_u = { .ports =
{ .sport = sport,
.dport = dport } } };
if (netchannel_ip_route_output_flow(&rt, &fl, 0))
goto no_route;
return dst_clone(&rt->u.dst);
no_route:
return NULL;
}
This is basically a copied input route code.
dst entry, obtained from route_get_raw() holds a pointer to network device.
--
Evgeniy Polyakov
next prev parent reply other threads:[~2007-05-04 12:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-04 12:48 How to find I/F to destination David Howells
2007-05-04 12:54 ` Evgeniy Polyakov [this message]
2007-05-04 13:04 ` David Howells
2007-05-04 13:06 ` David Howells
2007-05-04 13:08 ` David Howells
2007-05-04 13:16 ` Evgeniy Polyakov
2007-05-04 13:24 ` David Howells
2007-05-04 13:29 ` Evgeniy Polyakov
2007-05-04 13:33 ` David Howells
2007-05-04 13:43 ` Patrick McHardy
2007-05-04 13:55 ` David Howells
2007-05-04 13:59 ` Patrick McHardy
2007-05-05 9:13 ` Evgeniy Polyakov
2007-05-05 9:15 ` Evgeniy Polyakov
2007-05-04 13:20 ` Evgeniy Polyakov
2007-05-04 13:23 ` David Howells
2007-05-04 13:25 ` Evgeniy Polyakov
2007-05-04 13:00 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070504125438.GA5439@2ka.mipt.ru \
--to=johnpol@2ka.mipt.ru \
--cc=dhowells@redhat.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).