Skip to contentSkip to conversation

More nf_conntrack_sip questions

DISCUSSION Philip Prindeville 2 participants 14 messages Dec 2, 2008 – Dec 8, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

I did a little investigation into my one-way voice issue, and noticed that if I don't do voice-menus (i.e. where the Asterisk box itself generates the first outbound INVITE, then passes-through the 2nd INVITE once a handset picks up) then I get two-way voice (i.e. with sending the call directly to the phone). (In this topology, my Asterisk box is also my firewall/NATting router...)

If I enable the voice menus in the inbound dialplan, however, it can hear the voice menus, but not the called-party when they pick up their phone (extension).

So someone (either the SIP conntrack module on the Asterisk border firewall or else the SBC at the ILEC) is failing to look into the 2nd INVITE (i.e. we're not rewriting it properly as it goes by, or the SBC is failing to see it).

I've put traces up on ftp://ftp.redfish-solutions.com/ as:

trace-20081128-230313.br0
trace-20081128-230313.br1
trace-20081128-230415.br0
trace-20081128-230415.br1

The traces on interface "br1" are the "internal" network, with private 192.168.1.x addresses. The "br0" traces are after outbound NATting (and conntrack rewriting) has been applied.

This was done on a Linux 2.6.25.19 box with iptables v1.4.2.

Thanks,

-Philip

#1 lore raw
Quoted 5 lines · Philip Prindeville

I did a little investigation into my one-way voice issue, and noticed that if I don't do voice-menus (i.e. where the Asterisk box itself generates the first outbound INVITE, then passes-through the 2nd INVITE once a handset picks up) then I get two-way voice (i.e. with sending the call directly to the phone). (In this topology, my Asterisk box is also my firewall/NATting router...)

If I enable the voice menus in the inbound dialplan, however, it can hear the voice menus, but not the called-party when they pick up their phone (extension).

So someone (either the SIP conntrack module on the Asterisk border firewall or else the SBC at the ILEC) is failing to look into the 2nd INVITE (i.e. we're not rewriting it properly as it goes by, or the SBC is failing to see it).

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

#2 lore raw
Quoted 11 lines · Patrick McHardy
Quoted 5 lines · Philip Prindeville

I did a little investigation into my one-way voice issue, and noticed that if I don't do voice-menus (i.e. where the Asterisk box itself generates the first outbound INVITE, then passes-through the 2nd INVITE once a handset picks up) then I get two-way voice (i.e. with sending the call directly to the phone). (In this topology, my Asterisk box is also my firewall/NATting router...)

If I enable the voice menus in the inbound dialplan, however, it can hear the voice menus, but not the called-party when they pick up their phone (extension).

So someone (either the SIP conntrack module on the Asterisk border firewall or else the SBC at the ILEC) is failing to look into the 2nd INVITE (i.e. we're not rewriting it properly as it goes by, or the SBC is failing to see it).

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

For the PSTN's switch:

pbx*CLI> sip show peer sip_proxy
pbx*CLI>

 * Name       : sip_proxy
 Secret       : xxxx
 MD5Secret    : <Not set>
 Context      : ctc-incoming
 Subscr.Cont. : <Not set>
 Language     : 
 AMA flags    : Unknown
 Transfer mode: open
 CallingPres  : Presentation Allowed, Not Screened
 Callgroup    : 
 Pickupgroup  : 
 Mailbox      : 
 VM Extension : asterisk
 LastMsgsSent : 32767/65535
 Call limit   : 0
 Dynamic      : No
 Callerid     : "" <>
 MaxCallBR    : 384 kbps
 Expire       : -1
 Insecure     : no
 Nat          : RFC3581
 ACL          : No
 T38 pt UDPTL : No
 CanReinvite  : Yes
 PromiscRedir : No
 User=Phone   : No
 Video Support: No
 Trust RPID   : No
 Send RPID    : No
 Subscriptions: Yes
 Overlap dial : No
 DTMFmode     : rfc2833
 LastMsg      : 0
 ToHost       : 66.232.80.9
 Addr->IP     : 66.232.80.9 Port 5060
 Defaddr->IP  : 0.0.0.0 Port 0
 Def. Username: 
 SIP Options  : (none)
 Codecs       : 0x6 (gsm|ulaw)
 Codec Order  : (ulaw:20,gsm:20)

Auto-Framing: No
Status : Unmonitored
Useragent :
Reg. Contact :

pbx*CLI>

For the phone:

pbx*CLI> sip show peer office_1
pbx*CLI>

 * Name       : office_1
 Secret       : <Set>
 MD5Secret    : <Not set>
 Context      : redfish-internal
 Subscr.Cont. : <Not set>
 Language     : 
 AMA flags    : Unknown
 Transfer mode: open
 CallingPres  : Presentation Allowed, Not Screened
 Callgroup    : 
 Pickupgroup  : 
 Mailbox      : 112@redfish,xxxx
 VM Extension : voicemail
 LastMsgsSent : 0/0
 Call limit   : 0
 Dynamic      : Yes
 Callerid     : "Redfish Solutions" <112>
 MaxCallBR    : 384 kbps
 Expire       : 1780
 Insecure     : no
 Nat          : Always
 ACL          : No
 T38 pt UDPTL : No
 CanReinvite  : Yes
 PromiscRedir : No
 User=Phone   : No
 Video Support: No
 Trust RPID   : No
 Send RPID    : No
 Subscriptions: Yes
 Overlap dial : No
 DTMFmode     : rfc2833
 LastMsg      : 0
 ToHost       : 
 Addr->IP     : 192.168.1.7 Port 5060
 Defaddr->IP  : 0.0.0.0 Port 5060
 Def. Username: office_1
 SIP Options  : (none)
 Codecs       : 0x6 (gsm|ulaw)
 Codec Order  : (ulaw:20,gsm:20)

Auto-Framing: No
Status : OK (9 ms)
Useragent : Linksys/SPA942-5.1.15(a)
Reg. Contact : sip:[email protected]:5060

pbx*CLI>

#3 lore raw
Quoted 9 lines · Philip Prindeville
Quoted 8 lines · Patrick McHardy
Quoted 5 lines · Philip Prindeville

I did a little investigation into my one-way voice issue, and noticed that if I don't do voice-menus (i.e. where the Asterisk box itself generates the first outbound INVITE, then passes-through the 2nd INVITE once a handset picks up) then I get two-way voice (i.e. with sending the call directly to the phone). (In this topology, my Asterisk box is also my firewall/NATting router...)

If I enable the voice menus in the inbound dialplan, however, it can hear the voice menus, but not the called-party when they pick up their phone (extension).

So someone (either the SIP conntrack module on the Asterisk border firewall or else the SBC at the ILEC) is failing to look into the 2nd INVITE (i.e. we're not rewriting it properly as it goes by, or the SBC is failing to see it).

Quoted 7 lines
Quoted 3 lines

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

For the PSTN's switch:

CanReinvite : Yes

I vaguely recall some problem in the implementation of this feature, something with missing bridging of the RTP streams that was still necessary under some circumstances. Might be worth to try turning it off.

What about the module options?

#4 lore raw
Quoted 14 lines · Patrick McHardy
Quoted 13 lines · Philip Prindeville
Quoted 11 lines · Patrick McHardy
Quoted 5 lines · Philip Prindeville

I did a little investigation into my one-way voice issue, and noticed that if I don't do voice-menus (i.e. where the Asterisk box itself generates the first outbound INVITE, then passes-through the 2nd INVITE once a handset picks up) then I get two-way voice (i.e. with sending the call directly to the phone). (In this topology, my Asterisk box is also my firewall/NATting router...)

If I enable the voice menus in the inbound dialplan, however, it can hear the voice menus, but not the called-party when they pick up their phone (extension).

So someone (either the SIP conntrack module on the Asterisk border firewall or else the SBC at the ILEC) is failing to look into the 2nd INVITE (i.e. we're not rewriting it properly as it goes by, or the SBC is failing to see it).

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

Quoted 8 lines
Quoted 3 lines

For the PSTN's switch:

CanReinvite : Yes

I vaguely recall some problem in the implementation of this feature, something with missing bridging of the RTP streams that was still necessary under some circumstances. Might be worth to try turning it off.

Actually I think it was directrtpsetup. Still worth trying though.

Quoted 1 line

What about the module options?

#5 lore raw
In reply to Patrick McHardy
Quoted 16 lines · Patrick McHardy
Quoted 15 lines · Philip Prindeville
Quoted 11 lines · Patrick McHardy
Quoted 5 lines · Philip Prindeville

I did a little investigation into my one-way voice issue, and noticed that if I don't do voice-menus (i.e. where the Asterisk box itself generates the first outbound INVITE, then passes-through the 2nd INVITE once a handset picks up) then I get two-way voice (i.e. with sending the call directly to the phone). (In this topology, my Asterisk box is also my firewall/NATting router...)

If I enable the voice menus in the inbound dialplan, however, it can hear the voice menus, but not the called-party when they pick up their phone (extension).

So someone (either the SIP conntrack module on the Asterisk border firewall or else the SBC at the ILEC) is failing to look into the 2nd INVITE (i.e. we're not rewriting it properly as it goes by, or the SBC is failing to see it).

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

For the PSTN's switch:

Quoted 8 lines
Quoted 1 line

CanReinvite : Yes

I vaguely recall some problem in the implementation of this feature, something with missing bridging of the RTP streams that was still necessary under some circumstances. Might be worth to try turning it off.

What about the module options?

pbx*CLI> sip show settings
pbx*CLI>

Global Settings:
----------------

 SIP Port:               5060
 Bindaddress:            0.0.0.0
 Videosupport:           No
 AutoCreatePeer:         No
 Allow unknown access:   Yes
 Allow subscriptions:    Yes
 Allow overlap dialing:  No
 Promsic. redir:         No
 SIP domain support:     Yes
 Call to non-local dom.: Yes
 URI user is phone no:   No
 Our auth realm          asterisk
 Realm. auth:            No
 Always auth rejects:    No
 Call limit peers only:  No
 Direct RTP setup:       No
 User Agent:             Asterisk PBX
 MWI checking interval:  10 secs
 Reg. context:           (not set)
 Caller ID:              asterisk
 From: Domain:           
 Record SIP history:     Off
 Call Events:            Off
 IP ToS SIP:             CS3
 IP ToS RTP audio:       EF
 IP ToS RTP video:       AF41
 T38 fax pt UDPTL:       No
 RFC2833 Compensation:   No
 SIP realtime:           Disabled

Global Signalling Settings:
---------------------------

 Codecs:                 0x6 (gsm|ulaw)
 Codec Order:            ulaw:20,gsm:20
 T1 minimum:             100
 Relax DTMF:             No
 Compact SIP headers:    No
 RTP Keepalive:          0 (Disabled)
 RTP Timeout:            0 (Disabled)
 RTP Hold Timeout:       0 (Disabled)
 MWI NOTIFY mime type:   application/simple-message-summary
 DNS SRV lookup:         Yes
 Pedantic SIP support:   No
 Reg. min duration       60 secs
 Reg. max duration:      3600 secs
 Reg. default duration:  120 secs
 Outbound reg. timeout:  20 secs
 Outbound reg. attempts: 0
 Notify ringing state:   Yes
 Notify hold state:      No
 SIP Transfer mode:      open
 Max Call Bitrate:       384 kbps
 Auto-Framing:           No 

Default Settings:
-----------------

 Context:                INVALID
 Nat:                    RFC3581
 DTMF:                   rfc2833
 Qualify:                0
 Use ClientCode:         No
 Progress inband:        Never
 Language:               (Defaults to English)
 MOH Interpret:          default

MOH Suggest:
Voice Mail Extension: asterisk

----
pbx*CLI>

#6 lore raw
Quoted 11 lines · Philip Prindeville
Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Philip Prindeville
Quoted 3 lines · Patrick McHardy

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

For the PSTN's switch:

CanReinvite : Yes

Quoted 8 lines
Quoted 6 lines

I vaguely recall some problem in the implementation of this feature, something with missing bridging of the RTP streams that was still necessary under some circumstances. Might be worth to try turning it off.

What about the module options?

http://www.amazon.de/Applied-Cryptography-Protocols-Algorithms-Source/dp/0471117099/ref=sr_1_4?ie=UTF8&s=books-intl-de&qid=1228500191&sr=1-4

The SIP helper module options.

#7 lore raw
Quoted 17 lines · Patrick McHardy
Quoted 16 lines · Philip Prindeville
Quoted 15 lines · Patrick McHardy
Quoted 8 lines · Philip Prindeville
Quoted 3 lines · Patrick McHardy

What module options are you using for the SIP helper and how is call setup in asterisk configured (directrtpsetup, canreinvite, ...)?

For the PSTN's switch:

CanReinvite : Yes

I vaguely recall some problem in the implementation of this feature, something with missing bridging of the RTP streams that was still necessary under some circumstances. Might be worth to try turning it off.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

What about the module options?

http://www.amazon.de/Applied-Cryptography-Protocols-Algorithms-Source/dp/0471117099/ref=sr_1_4?ie=UTF8&s=books-intl-de&qid=1228500191&sr=1-4

The SIP helper module options.

Oh, sorry.... just:

ports=5060:5063

Ummm... what's the Amazon link about?

#8 lore raw
Quoted 8 lines · Philip Prindeville
Quoted 7 lines · Patrick McHardy
Quoted 4 lines · Philip Prindeville
Quoted 1 line

What about the module options?

http://www.amazon.de/Applied-Cryptography-Protocols-Algorithms-Source/dp/0471117099/ref=sr_1_4?ie=UTF8&s=books-intl-de&qid=1228500191&sr=1-4

Quoted 5 lines
Quoted 1 line

The SIP helper module options.

Oh, sorry.... just:

ports=5060:5063

Try sip_direct_media=0

Quoted 2 lines

Ummm... what's the Amazon link about?

Hehe .. that slipped in from a chat window :)

#9 lore raw
Quoted 9 lines · Patrick McHardy
Quoted 8 lines · Philip Prindeville
Quoted 7 lines · Patrick McHardy
Quoted 4 lines · Philip Prindeville
Quoted 1 line

What about the module options?

http://www.amazon.de/Applied-Cryptography-Protocols-Algorithms-Source/dp/0471117099/ref=sr_1_4?ie=UTF8&s=books-intl-de&qid=1228500191&sr=1-4

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

The SIP helper module options.

Oh, sorry.... just:

ports=5060:5063

Try sip_direct_media=0

That's not an option in 2.6.25.19... when did it get introduced? Do we need to run a more recent version to pick up useful fixes?

Also, does 2.6.25.19 include the port-range helpers?

Unless I'm misunderstanding something....

-Philip

Quoted 5 lines
Quoted 3 lines

Ummm... what's the Amazon link about?

Hehe .. that slipped in from a chat window :)

#10 lore raw
Quoted 8 lines · Philip Prindeville
Quoted 1 line · Patrick McHardy

Try sip_direct_media=0

That's not an option in 2.6.25.19... when did it get introduced? Do we need to run a more recent version to pick up useful fixes?

Also, does 2.6.25.19 include the port-range helpers?

Unless I'm misunderstanding something....

That version is known not to work very well, 2.6.26 includes a largely rewritten version.

This is a backport to 2.6.25:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.25-sip.git

#11 lore raw
Quoted 8 lines · Patrick McHardy
Quoted 7 lines · Philip Prindeville
Quoted 1 line · Patrick McHardy

Try sip_direct_media=0

That's not an option in 2.6.25.19... when did it get introduced? Do we need to run a more recent version to pick up useful fixes?

Also, does 2.6.25.19 include the port-range helpers?

Quoted 8 lines
Quoted 1 line

Unless I'm misunderstanding something....

That version is known not to work very well, 2.6.26 includes a largely rewritten version.

This is a backport to 2.6.25:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.25-sip.git

Well, it might be easier to simply jump to 2.6.26.8 (unless there's something horribly wrong with that version).

Just means going through patch hell again as we munge patches for ocf, imq, squashfs, unionfs, multi-routing, etc.

Say, I've been wondering about that: what is the status of dead default gateway detection? Not sure why it requires a patch and isn't just something selectable via CONFIG_xxx...

-Philip

#12 lore raw
Quoted 7 lines · Philip Prindeville
Quoted 6 lines · Patrick McHardy

Philip Prindeville wrote:
That version is known not to work very well, 2.6.26 includes a largely rewritten version.

This is a backport to 2.6.25:

Quoted 7 lines
Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.25-sip.git

Well, it might be easier to simply jump to 2.6.26.8 (unless there's something horribly wrong with that version).

Just means going through patch hell again as we munge patches for ocf, imq, squashfs, unionfs, multi-routing, etc.

Say, I've been wondering about that: what is the status of dead default gateway detection? Not sure why it requires a patch and isn't just something selectable via CONFIG_xxx...

I'm guessing the patch hasn't been submitted yet.

#13 lore raw
Quoted 10 lines · Patrick McHardy
Quoted 9 lines · Philip Prindeville
Quoted 7 lines · Patrick McHardy

Philip Prindeville wrote:
That version is known not to work very well, 2.6.26 includes a largely rewritten version.

This is a backport to 2.6.25:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.25-sip.git

Quoted 7 lines
Quoted 5 lines

Well, it might be easier to simply jump to 2.6.26.8 (unless there's something horribly wrong with that version).

Just means going through patch hell again as we munge patches for ocf, imq, squashfs, unionfs, multi-routing, etc.

Say, I've been wondering about that: what is the status of dead default gateway detection? Not sure why it requires a patch and isn't just something selectable via CONFIG_xxx...

I'm guessing the patch hasn't been submitted yet.

This might be more of a question for linux-net.

I tried to take the 2.6.25.15 patches (which worked with .19 just fine) and rewrite them for 2.6.26.8, but the changes related to CONFIG_NET_NS seem to be fouling us up... little confused about that, because the code:

+ if (ip_route_output_key(out->nd_net, &rt, &fl) != 0) {
+ /* Funky routing can do this. */
+ if (net_ratelimit())
+ printk("MASQUERADE:"
+ " No route: Rusty's brain broke!\n");
+ return NF_DROP;
+ }

compiled just fine in 2.6.25.19 as I said...

I haven't groveled through all the changes from 2.6.25.19 to 2.6.26.8... In 2.6.26 I'm seeing:

#ifdef CONFIG_NET_NS
       /* Network namespace this network device is inside */
       struct net              *nd_net;

#endif

in include/linux/netdevice.h. In 2.6.25.19 I see:

       /* Network namespace this network device is inside */
       struct net              *nd_net;

(no #ifdef's).

Can someone please look over my patch and confirm it's correctness? Mostly I took:

+ if (fib_lookup(dev->nd_net, &fl, &res) != 0)
+ continue;
+ if (res.type != RTN_UNICAST &&
+ res.type != RTN_LOCAL) {
+ fib_res_put(&res);
+ continue;
+ }

and rewrote it as:

+ #ifdef CONFIG_NET_NS
+ if (fib_lookup(dev->nd_net, &fl, &res) != 0)
+ #else
+ if (fib_lookup(&init_net, &fl, &res) != 0)
+ #endif
+ continue;
+ if (res.type != RTN_UNICAST &&
+ res.type != RTN_LOCAL) {
+ fib_res_put(&res);
+ continue;
+ }

Ditto for:

+ #ifdef CONFIG_NET_NS
+ if (ip_route_output_key(out->nd_net, &rt, &fl) != 0) {
+ #else
+ if (ip_route_output_key(&init_net, &rt, &fl) != 0) {
+ #endif
+ /* Funky routing can do this. */
+ if (net_ratelimit())
+ printk("MASQUERADE:"
+ " No route: Rusty's brain broke!\n");
+ return NF_DROP;
+ }

Might be handy to have a convenience wrapper that takes a struct net_device *, and returns its ->nd_net if CONFIG_NET_NS is enabled, and otherwise returns &init_net...

Maybe like nf_forward_net() works, but simpler. Or should I have written the patches above using nf_local_out_net() instead???

It would be nice if the patch (the original, not my tweaked version) became part of the upstream source. One of the things about the patch is that it's not a compile-time option. It has sequences such as:

-#ifdef CONFIG_IP_ROUTE_MULTIPATH
- if (FIB_RES_DEV(res) == dev || res.fi->fib_nhs > 1)
-#else

       if (FIB_RES_DEV(res) == dev)

-#endif

and:

-#ifdef CONFIG_IP_ROUTE_MULTIPATH

               fib_sync_up(ifa->ifa_dev->dev);

-#endif

which I don't understand. You can't simple turn it off or on via CONFIG_IP_ROUTE_MULTIPATH=y ...

Thanks,

-Philip

include/linux/rtnetlink.h renamed from linux/include/linux/rtnetlink.h +2 -0
diff -urp v2.6.25/linux/include/linux/rtnetlink.h linux/include/linux/rtnetlink.h
@@ -303,6 +303,8 @@ struct rtnexthop
 #define RTNH_F_DEAD		1	/* Nexthop is dead (used by multipath)	*/
 #define RTNH_F_PERVASIVE	2	/* Do recursive gateway lookup	*/
 #define RTNH_F_ONLINK		4	/* Gateway is forced on link	*/
+#define RTNH_F_SUSPECT		8	/* We don't know the real state	*/
+#define RTNH_F_BADSTATE		(RTNH_F_DEAD | RTNH_F_SUSPECT)
 
 /* Macros to handle hexthops */
 
include/net/flow.h renamed from linux/include/net/flow.h +4 -0
diff -urp v2.6.25/linux/include/net/flow.h linux/include/net/flow.h
@@ -19,6 +19,8 @@ struct flowi {
 		struct {
 			__be32			daddr;
 			__be32			saddr;
+			__be32			lsrc;
+			__be32			gw;
 			__u8			tos;
 			__u8			scope;
 		} ip4_u;
@@ -43,6 +45,8 @@ struct flowi {
 #define fl6_flowlabel	nl_u.ip6_u.flowlabel
 #define fl4_dst		nl_u.ip4_u.daddr
 #define fl4_src		nl_u.ip4_u.saddr
+#define fl4_lsrc	nl_u.ip4_u.lsrc
+#define fl4_gw		nl_u.ip4_u.gw
 #define fl4_tos		nl_u.ip4_u.tos
 #define fl4_scope	nl_u.ip4_u.scope
 
include/net/ip_fib.h renamed from linux/include/net/ip_fib.h +4 -0
diff -urp v2.6.25/linux/include/net/ip_fib.h linux/include/net/ip_fib.h
@@ -207,6 +207,8 @@ extern int fib_lookup(struct net *n, str
 extern struct fib_table *fib_new_table(struct net *net, u32 id);
 extern struct fib_table *fib_get_table(struct net *net, u32 id);
 
+extern int fib_result_table(struct fib_result *res);
+
 #endif /* CONFIG_IP_MULTIPLE_TABLES */
 
 /* Exported by fib_frontend.c */
@@ -276,4 +278,6 @@ static inline void fib_proc_exit(struct 
 }
 #endif
 
+extern rwlock_t fib_nhflags_lock;
+
 #endif  /* _NET_FIB_H */
include/net/netfilter/nf_nat.h renamed from linux/include/net/netfilter/nf_nat.h +7 -0
diff -urp v2.6.25/linux/include/net/netfilter/nf_nat.h linux/include/net/netfilter/nf_nat.h
@@ -77,6 +77,13 @@ struct nf_conn_nat
 #endif
 };
 
+/* Call input routing for SNAT-ed traffic */
+extern unsigned int ip_nat_route_input(unsigned int hooknum,
+				       struct sk_buff *skb,
+				       const struct net_device *in,
+				       const struct net_device *out,
+				       int (*okfn)(struct sk_buff *));
+
 /* Set up the info structure to map into this range. */
 extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
 				      const struct nf_nat_range *range,
include/net/route.h renamed from linux/include/net/route.h +1 -0
diff -urp v2.6.25/linux/include/net/route.h linux/include/net/route.h
@@ -116,6 +116,7 @@
 extern int		ip_route_output_key(struct net *, struct rtable **, struct flowi *flp);
 extern int		ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags);
 extern int		ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin);
+extern int		ip_route_input_lookup(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin, __be32 lsrc);
 extern unsigned short	ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev);
 extern void		ip_rt_send_redirect(struct sk_buff *skb);
 
net/bridge/br_netfilter.c renamed from linux/net/bridge/br_netfilter.c +4 -0
diff -urp v2.6.25/linux/net/bridge/br_netfilter.c linux/net/bridge/br_netfilter.c
@@ -325,6 +325,10 @@ static int br_nf_pre_routing_finish(stru
 	struct nf_bridge_info *nf_bridge = skb->nf_bridge;
 	int err;
 
+	/* Old skb->dst is not expected, it is lost in all cases */
+	dst_release(skb->dst);
+	skb->dst = NULL;
+
 	if (nf_bridge->mask & BRNF_PKT_TYPE) {
 		skb->pkt_type = PACKET_OTHERHOST;
 		nf_bridge->mask ^= BRNF_PKT_TYPE;
net/ipv4/fib_frontend.c renamed from linux/net/ipv4/fib_frontend.c +20 -12
diff -urp v2.6.25/linux/net/ipv4/fib_frontend.c linux/net/ipv4/fib_frontend.c
@@ -49,6 +49,8 @@
 
 #ifndef CONFIG_IP_MULTIPLE_TABLES
 
+#define FIB_RES_TABLE(r) (RT_TABLE_MAIN)
+
 static int __net_init fib4_rules_init(struct net *net)
 {
 	struct fib_table *local_table, *main_table;
@@ -73,6 +75,8 @@ fail:
 }
 #else
 
+#define FIB_RES_TABLE(r) (fib_result_table(r))
+
 struct fib_table *fib_new_table(struct net *net, u32 id)
 {
 	struct fib_table *tb;
@@ -127,7 +131,8 @@ void fib_select_default(struct net *net,
 	table = res->r->table;
 #endif
 	tb = fib_get_table(net, table);
-	if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK)
+	if ((FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) ||
+	    FIB_RES_NH(*res).nh_scope == RT_SCOPE_HOST)
 		tb->tb_select_default(tb, flp, res);
 }
 
@@ -241,6 +246,9 @@ int fib_validate_source(__be32 src, __be
 					.tos = tos } },
 			    .iif = oif };
 	struct fib_result res;
+	int table;
+	unsigned char prefixlen;
+	unsigned char scope;
 	int no_addr, rpf;
 	int ret;
 	struct net *net;
@@ -264,31 +272,35 @@ int fib_validate_source(__be32 src, __be
 		goto e_inval_res;
 	*spec_dst = FIB_RES_PREFSRC(res);
 	fib_combine_itag(itag, &res);
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
-	if (FIB_RES_DEV(res) == dev || res.fi->fib_nhs > 1)
-#else
 	if (FIB_RES_DEV(res) == dev)
-#endif
 	{
 		ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
 		fib_res_put(&res);
 		return ret;
 	}
+	table = FIB_RES_TABLE(&res);
+	prefixlen = res.prefixlen;
+	scope = res.scope;
 	fib_res_put(&res);
 	if (no_addr)
 		goto last_resort;
-	if (rpf)
-		goto e_inval;
 	fl.oif = dev->ifindex;
 
 	ret = 0;
 	if (fib_lookup(net, &fl, &res) == 0) {
-		if (res.type == RTN_UNICAST) {
+		if (res.type == RTN_UNICAST &&
+		    ((table == FIB_RES_TABLE(&res) &&
+		      res.prefixlen >= prefixlen && res.scope >= scope) ||
+		     !rpf)) {
 			*spec_dst = FIB_RES_PREFSRC(res);
 			ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
+			fib_res_put(&res);
+			return ret;
 		}
 		fib_res_put(&res);
 	}
+	if (rpf)
+		goto e_inval;
 	return ret;
 
 last_resort:
@@ -911,9 +923,7 @@ static int fib_inetaddr_event(struct not
 	switch (event) {
 	case NETDEV_UP:
 		fib_add_ifaddr(ifa);
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
 		fib_sync_up(ifa->ifa_dev->dev);
-#endif
 		rt_cache_flush(-1);
 		break;
 	case NETDEV_DOWN:
@@ -949,9 +959,7 @@ static int fib_netdev_event(struct notif
 		for_ifa(in_dev) {
 			fib_add_ifaddr(ifa);
 		} endfor_ifa(in_dev);
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
 		fib_sync_up(dev);
-#endif
 		rt_cache_flush(-1);
 		break;
 	case NETDEV_DOWN:
net/ipv4/fib_hash.c renamed from linux/net/ipv4/fib_hash.c +43 -17

122 lines not on this page · raw message

net/ipv4/fib_lookup.h renamed from linux/net/ipv4/fib_lookup.h +3 -1
diff -urp v2.6.25/linux/net/ipv4/fib_lookup.h linux/net/ipv4/fib_lookup.h
@@ -8,6 +8,7 @@
 struct fib_alias {
 	struct list_head	fa_list;
 	struct fib_info		*fa_info;
+	int			fa_last_dflt;
 	u8			fa_tos;
 	u8			fa_type;
 	u8			fa_scope;
@@ -38,7 +39,8 @@ extern struct fib_alias *fib_find_alias(
 					u8 tos, u32 prio);
 extern int fib_detect_death(struct fib_info *fi, int order,
 			    struct fib_info **last_resort,
-			    int *last_idx, int dflt);
+			    int *last_idx, int *dflt, int *last_nhsel,
+			    const struct flowi *flp);
 
 static inline void fib_result_assign(struct fib_result *res,
 				     struct fib_info *fi)
net/ipv4/fib_rules.c renamed from linux/net/ipv4/fib_rules.c +5 -0
diff -urp v2.6.25/linux/net/ipv4/fib_rules.c linux/net/ipv4/fib_rules.c
@@ -54,6 +54,11 @@ u32 fib_rules_tclass(struct fib_result *
 }
 #endif
 
+int fib_result_table(struct fib_result *res)
+{
+	return res->r->table;
+}
+
 int fib_lookup(struct net *net, struct flowi *flp, struct fib_result *res)
 {
 	struct fib_lookup_arg arg = {
net/ipv4/fib_semantics.c renamed from linux/net/ipv4/fib_semantics.c +226 -67

436 lines not on this page · raw message

net/ipv4/netfilter/ipt_MASQUERADE.c renamed from linux/net/ipv4/netfilter/ipt_MASQUERADE.c +25 -6
diff -urp v2.6.25/linux/net/ipv4/netfilter/ipt_MASQUERADE.c linux/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -59,7 +59,7 @@ masquerade_tg(struct sk_buff *skb, const
 	enum ip_conntrack_info ctinfo;
 	struct nf_nat_range newrange;
 	const struct nf_nat_multi_range_compat *mr;
-	const struct rtable *rt;
+	struct rtable *rt;
 	__be32 newsrc;
 
 	NF_CT_ASSERT(hooknum == NF_INET_POST_ROUTING);
@@ -77,13 +77,32 @@ masquerade_tg(struct sk_buff *skb, const
 		return NF_ACCEPT;
 
 	mr = targinfo;
-	rt = skb->rtable;
-	newsrc = inet_select_addr(out, rt->rt_gateway, RT_SCOPE_UNIVERSE);
-	if (!newsrc) {
-		printk("MASQUERADE: %s ate my IP address\n", out->name);
-		return NF_DROP;
+
+	{
+		struct flowi fl = { .nl_u = { .ip4_u =
+					      { .daddr = ip_hdr(skb)->daddr,
+						.tos = (RT_TOS(ip_hdr(skb)->tos) |
+							RTO_CONN),
+						.gw = ((struct rtable *) skb->dst)->rt_gateway,
+					      } },
+				    .mark = skb->mark,
+				    .oif = out->ifindex };
+ #ifdef CONFIG_NET_NS
+		if (ip_route_output_key(out->nd_net, &rt, &fl) != 0) {
+ #else
+		if (ip_route_output_key(&init_net, &rt, &fl) != 0) {
+ #endif
+			/* Funky routing can do this. */
+			if (net_ratelimit())
+				printk("MASQUERADE:"
+				       " No route: Rusty's brain broke!\n");
+			return NF_DROP;
+		}
 	}
 
+	newsrc = rt->rt_src;
+	ip_rt_put(rt);
+
 	write_lock_bh(&masq_lock);
 	nat->masq_index = out->ifindex;
 	write_unlock_bh(&masq_lock);
net/ipv4/netfilter/nf_nat_core.c renamed from linux/net/ipv4/netfilter/nf_nat_core.c +46 -0

52 lines not on this page · raw message

net/ipv4/netfilter/nf_nat_standalone.c renamed from linux/net/ipv4/netfilter/nf_nat_standalone.c +8 -0
diff -urp v2.6.25/linux/net/ipv4/netfilter/nf_nat_standalone.c linux/net/ipv4/netfilter/nf_nat_standalone.c
@@ -282,6 +282,14 @@ static struct nf_hook_ops nf_nat_ops[] _
 		.hooknum	= NF_INET_PRE_ROUTING,
 		.priority	= NF_IP_PRI_NAT_DST,
 	},
+	/* Before routing, route before mangling */
+	{
+		.hook		= ip_nat_route_input,
+		.owner		= THIS_MODULE,
+		.pf		= PF_INET,
+		.hooknum	= NF_INET_PRE_ROUTING,
+		.priority	= NF_IP_PRI_LAST-1,
+	},
 	/* After packet filtering, change source */
 	{
 		.hook		= nf_nat_out,
net/ipv4/route.c renamed from linux/net/ipv4/route.c +55 -16

242 lines not on this page · raw message