lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 4 May 2007 16:54:38 +0400
From:	Evgeniy Polyakov <johnpol@....mipt.ru>
To:	David Howells <dhowells@...hat.com>
Cc:	netdev@...r.kernel.org, Patrick McHardy <kaber@...sh.net>
Subject: Re: How to find I/F to destination

On Fri, May 04, 2007 at 01:48:48PM +0100, David Howells (dhowells@...hat.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
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ