[patch] ip_dynaddr re-enable

From: Xuan Baldauf (xuan--lkml@baldauf.org)
Date: Mon Apr 16 2001 - 15:04:27 EST


Hello,

about one or two months ago, I had the problem that
/proc/sys/net/ipv4/ip_dynaddr did not work. I analyzed the
problem and somehow came to a solution which I have
forgotten. But a patch which solved the problem against
2.4.1 which also works for 2.4.2-pre4 remained. Here it is.

Xuân.


--- linux/net/ipv4/tcp_ipv4.c.orig Tue Jan 30 11:37:56 2001
+++ linux/net/ipv4/tcp_ipv4.c Tue Jan 30 13:31:14 2001
@@ -1774,6 +1774,11 @@
         u32 daddr;
         int err;
 
+ if (sysctl_ip_dynaddr > 2) {
+ printk(KERN_INFO "tcp_v4_rebuild_header(): sysctl_ip_dynaddr=%d, sk->userlocks=0x%x, rt==0x%x, src=%d.%d.%d.%d, sk->state=%d,sk->userlocks=0x%x.\n",
+ sysctl_ip_dynaddr, sk->userlocks,rt,NIPQUAD(sk->saddr),sk->state,sk->userlocks);
+ }
+
         /* Route is OK, nothing to do. */
         if (rt != NULL)
                 return 0;
@@ -1783,9 +1788,26 @@
         if(sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr)
                 daddr = sk->protinfo.af_inet.opt->faddr;
 
+ if ((sysctl_ip_dynaddr) && (sk->state == TCP_SYN_SENT) && (!(sk->userlocks & SOCK_BINDADDR_LOCK)) ) {
+ err = tcp_v4_reselect_saddr(sk);
+
+ if (sysctl_ip_dynaddr > 2) {
+ printk(KERN_INFO "tcp_v4_rebuild_header(): tcp_v4_reselect_saddr(sk)=%d.\n",err);
+ }
+
+ if (err!=0) {
+ sk->err_soft=-err;
+ /* sk->error_report(sk); */
+ }
+ }
+
         err = ip_route_output(&rt, daddr, sk->saddr,
                               RT_TOS(sk->protinfo.af_inet.tos) | RTO_CONN | sk->localroute,
                               sk->bound_dev_if);
+ if (sysctl_ip_dynaddr > 2) {
+ printk(KERN_INFO "tcp_v4_rebuild_header(): err=%d.\n",
+ err);
+ }
         if (!err) {
                 __sk_dst_set(sk, &rt->u.dst);
                 /* sk->route_caps = rt->u.dst.dev->features; */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 23 2001 - 21:00:09 EST