Re: Wrong outgoing interface with multiple routing tables

2009-07-28 Thread Oleg Sharoyko
Julian Elischer wrote: ok so here's my final patch. This is taken against -current. so it may not patch exactly cleanly. it's not quite minimal as I'm cleaning up something too, but could you check it works? Works with 7.2. Thanks! if you have ipv6 it might be nice to check that ipv6 doesn

Re: Wrong outgoing interface with multiple routing tables

2009-07-28 Thread Julian Elischer
Oleg Sharoyko wrote: Julian Elischer wrote: I'll get that checked in! Please, also take a look at _syncache_add() in tcp_syncache.c There is some code which looks strange, at least at first sight. Won't bcopy() overwrite assigned value of sc->sc_inc.inc_fibnum ? /* XXX-BZ this fi

Re: Wrong outgoing interface with multiple routing tables

2009-07-28 Thread Oleg Sharoyko
Julian Elischer wrote: I'll get that checked in! Please, also take a look at _syncache_add() in tcp_syncache.c There is some code which looks strange, at least at first sight. Won't bcopy() overwrite assigned value of sc->sc_inc.inc_fibnum ? /* XXX-BZ this fib assignment is just u

Re: Wrong outgoing interface with multiple routing tables

2009-07-28 Thread Julian Elischer
Oleg Sharoyko wrote: On Mon, 2009-07-27 at 16:24 -0700, Julian Elischer wrote: in addition to the patches already sent you might like to add the following line to netinet/tcp_input.c } inc.inc_fport = th->th_sport; inc.inc_lport = th->th_dport;

Re: Wrong outgoing interface with multiple routing tables

2009-07-28 Thread Julian Elischer
Oleg Sharoyko wrote: On Mon, 2009-07-27 at 16:24 -0700, Julian Elischer wrote: in addition to the patches already sent you might like to add the following line to netinet/tcp_input.c } inc.inc_fport = th->th_sport; inc.inc_lport = th->th_dport;

Re: Wrong outgoing interface with multiple routing tables

2009-07-28 Thread Oleg Sharoyko
On Mon, 2009-07-27 at 16:24 -0700, Julian Elischer wrote: > > in addition to the patches already sent you might like to add the > > following line to netinet/tcp_input.c > > > > } > > inc.inc_fport = th->th_sport; > > inc.inc_lport = th->th_dport;

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Julian Elischer wrote: Oleg Sharoyko wrote: Julian Elischer wrote: great.. in your simple server, can you do the sockopt on the socket AFTER you did the listen()? (just as a test). Doesn't help. I have also tried to add setsockopt() after accept() (for a new socket) and in this case the o

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Oleg Sharoyko wrote: Julian Elischer wrote: great.. in your simple server, can you do the sockopt on the socket AFTER you did the listen()? (just as a test). Doesn't help. I have also tried to add setsockopt() after accept() (for a new socket) and in this case the only packet that is being

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Oleg Sharoyko wrote: Julian Elischer wrote: great.. in your simple server, can you do the sockopt on the socket AFTER you did the listen()? (just as a test). Doesn't help. I have also tried to add setsockopt() after accept() (for a new socket) and in this case the only packet that is being

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Julian Elischer wrote: So there are two possible ways a daemon might assign a fib to a socket that it is accepting: 1/ the accept socket could take the FIB of the process. 2/ the accept socket could take the fib of the incoming SYN packet. I chose #1, but it is possible something in changes

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Oleg Sharoyko
Julian Elischer wrote: great.. in your simple server, can you do the sockopt on the socket AFTER you did the listen()? (just as a test). Doesn't help. I have also tried to add setsockopt() after accept() (for a new socket) and in this case the only packet that is being sent out via wrong i

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Oleg Sharoyko wrote: Julian Elischer wrote: does it still fail if you run it in foreground mode (no daemonizing)? Yes. I actually test sshd in foreground mode (-D tells sshd to not go into background). I have also checked a very simple client/server where server called setsockopt(SO_SETFIB

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
So there are two possible ways a daemon might assign a fib to a socket that it is accepting: 1/ the accept socket could take the FIB of the process. 2/ the accept socket could take the fib of the incoming SYN packet. I chose #1, but it is possible something in changes between 6 and 7 broke th

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Oleg Sharoyko
Julian Elischer wrote: does it still fail if you run it in foreground mode (no daemonizing)? Yes. I actually test sshd in foreground mode (-D tells sshd to not go into background). I have also checked a very simple client/server where server called setsockopt(SO_SETFIB, 1) and got the same

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Oleg Sharoyko wrote: Julian Elischer wrote: r61net-fbsdhost-1, / # setfib 1 /usr/sbin/sshd -o 'ListenAddress 195.208.245.229:' -D Are you running this from inetd?. (doesnt look like it) No, I run this from shell merely for test purposes. First I tried to start sshd in a usual way in a

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Oleg Sharoyko
Julian Elischer wrote: r61net-fbsdhost-1, / # setfib 1 /usr/sbin/sshd -o 'ListenAddress 195.208.245.229:' -D Are you running this from inetd?. (doesnt look like it) No, I run this from shell merely for test purposes. First I tried to start sshd in a usual way in a jail, but came to thi

Re: Wrong outgoing interface with multiple routing tables

2009-07-27 Thread Julian Elischer
Oleg Sharoyko wrote: Hello! I'm having a trouble with multiple routing tables (FreeBSD 7.2 release). Either I'm missing something in my setup or packets for daemons started with setfib are being sent out via the wrong interface. What I'd like to implement: em0 - internal management network wit