raw socket, bpf, netgraph, etc

2000-02-14 Thread Yevmenkin, Maksim N, CSCIO

Hello All,

Is it possible to get access to link layer (AF_LINK) via raw socket?
kind of Linux SOCK_PACKET. It seems to me that it is not. (hope I wrong :)

I can access raw IP via socket(AF_INET, SOCK_RAW, IPPROTO_RAW)
and event get access to IP header with setsockopt. But not AF_LINK :(

On the other hand is bpf. but here is the small problem. i have interface
with
bpf attached to it. when i write to /dev/bpf i got the same packet back.
kind of loop. the only solution is to filter these packets. but there is no
way to find out which packet i wrote, and which is received from outside.

i was thinking about netgraph. would't it be nice to have netgraph interface
in each network driver? 

Any ideas?

Thanks,
emax


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: raw socket, bpf, netgraph, etc

2000-02-14 Thread David Malone

On Mon, Feb 14, 2000 at 10:33:47AM -0800, Archie Cobbs wrote:
> Yevmenkin, Maksim N, CSCIO writes:
> > i was thinking about netgraph. would't it be nice to have netgraph interface
> > in each network driver? 
> 
> You already do. See ng_ether(8).
> 
> Compile your kernel with options NETGRAPH and then each Ethernet
> interface is a netgraph node. Take control of it by connecting
> to the "divert" hook.

I was trying to figure out if it is possible to route stuff out on
a particular interface based on source address using netgraph. At
the moment we have an NFS server which pretends to be two machines
on the same subnet. To get this to work we're using a small hack
in the ipfw divert code. I looked at the netgraph man pages and
reckoned it might be possible to do somthing like:

   fxp0
  /
ng0 -> bpf 
  \
   fxp1

then ifconfig ng0 up with both IP addresses and use the bpf to
determine which ethernet card to transmit it on. However, I don't
think this will work. First 'cos arp stuff will probably be broken
and second because ng0 is a point to point device and won't correctly
encapsulate packets for ethernet.

Am I correct in thinking that this isn't currently possible with the
net graph nodes currently available?

David.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: raw socket, bpf, netgraph, etc

2000-02-14 Thread Archie Cobbs

David Malone writes:
> > Compile your kernel with options NETGRAPH and then each Ethernet
> > interface is a netgraph node. Take control of it by connecting
> > to the "divert" hook.
> 
> I was trying to figure out if it is possible to route stuff out on
> a particular interface based on source address using netgraph. At
> the moment we have an NFS server which pretends to be two machines
> on the same subnet. To get this to work we're using a small hack
> in the ipfw divert code. I looked at the netgraph man pages and
> reckoned it might be possible to do somthing like:
> 
>fxp0
>   /
> ng0 -> bpf 
>   \
>fxp1
> 
> then ifconfig ng0 up with both IP addresses and use the bpf to
> determine which ethernet card to transmit it on. However, I don't
> think this will work. First 'cos arp stuff will probably be broken
> and second because ng0 is a point to point device and won't correctly
> encapsulate packets for ethernet.

You're right that that won't work .. you'd be sending raw IP
frames on the wire without 14 byte Ethernet headers.

> Am I correct in thinking that this isn't currently possible with the
> net graph nodes currently available?

I think so.. you would have to write a new new node type to add/strip
the headers at least.

That brings up a good point though..  the ng_iface(8) node type
should allow it to configured as a non-point-to-point interface.

Ah.. just looked at if_tun.c which does this.. it's trivial.
I'll probably check something in after 4.0 then.

But even with that change you'd need an add/strip headers thing.
In fact, that's another node type I want to write.. just a simple
thing that adds & strips headers off packets... or this could be
folded into the BPF node type (a BPF program returns a length,
after all).

-Archie

___
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: raw socket, bpf, netgraph, etc

2000-02-14 Thread Archie Cobbs

Yevmenkin, Maksim N, CSCIO writes:
> i was thinking about netgraph. would't it be nice to have netgraph interface
> in each network driver? 

You already do. See ng_ether(8).

Compile your kernel with options NETGRAPH and then each Ethernet
interface is a netgraph node. Take control of it by connecting
to the "divert" hook.

-Archie

___
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message