svn commit: r226224 - head/sys/netinet

2011-10-10 Thread Qing Li
Author: qingli
Date: Mon Oct 10 17:41:11 2011
New Revision: 226224
URL: http://svn.freebsd.org/changeset/base/226224

Log:
  All indirect routes will fail the rtcheck, except for a special host
  route where the destination IP and the gateway IP is the same. This
  special case handling is only meant for backward compatibility reason.
  The last commit introduced a bug in the route check logic, where a
  valid special case is treated as an error. This patch fixes that bug
  along with some code cleanup.
  
  Suggested by: gleb
  Reviewed by:  kmacy, discussed with gleb
  MFC after:1 day

Modified:
  head/sys/netinet/in.c

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Mon Oct 10 17:39:58 2011(r226223)
+++ head/sys/netinet/in.c   Mon Oct 10 17:41:11 2011(r226224)
@@ -1414,8 +1414,6 @@ static int
 in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr 
*l3addr)
 {
struct rtentry *rt;
-   struct ifnet *xifp;
-   int error = 0;
 
KASSERT(l3addr-sa_family == AF_INET,
(sin_family %d, l3addr-sa_family));
@@ -1432,21 +1430,16 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
 * such as MANET, and the interface is of the correct type, then
 * allow for ARP to proceed.
 */
-   if (rt-rt_flags  (RTF_GATEWAY | RTF_HOST)) {
-   xifp = rt-rt_ifp;
-   
-   if (xifp  (xifp-if_type != IFT_ETHER ||
-(xifp-if_flags  (IFF_NOARP | IFF_STATICARP)) != 0))
-   error = EINVAL;
-
-   if (memcmp(rt-rt_gateway-sa_data, l3addr-sa_data,
-   sizeof(in_addr_t)) != 0)
-   error = EINVAL;
-   }
-
if (rt-rt_flags  RTF_GATEWAY) {
-   RTFREE_LOCKED(rt);
-   return (EINVAL);
+   if (!(rt-rt_flags  RTF_HOST) || !rt-rt_ifp ||
+   rt-rt_ifp-if_type != IFT_ETHER ||
+ (rt-rt_ifp-if_flags  
+  (IFF_NOARP | IFF_STATICARP)) != 0 ||
+ memcmp(rt-rt_gateway-sa_data, l3addr-sa_data,
+sizeof(in_addr_t)) != 0) {
+   RTFREE_LOCKED(rt);
+   return (EINVAL);
+   }
}
 
/*
@@ -1455,32 +1448,31 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
 * interfaces have the same prefix. An incoming packet arrives
 * on one interface and the corresponding outgoing packet leaves
 * another interface.
-* 
 */
if (rt-rt_ifp != ifp) {
-   char *sa, *mask, *addr, *lim;
+   const char *sa, *mask, *addr, *lim;
int len;
 
-   sa = (char *)rt_key(rt);
-   mask = (char *)rt_mask(rt);
-   addr = (char *)__DECONST(struct sockaddr *, l3addr);
-   len = ((struct sockaddr_in *)__DECONST(struct sockaddr *, 
l3addr))-sin_len;
+   sa = (const char *)rt_key(rt);
+   mask = (const char *)rt_mask(rt);
+   addr = (const char *)l3addr;
+   len = ((const struct sockaddr_in *)l3addr)-sin_len;
lim = addr + len;
 
for ( ; addr  lim; sa++, mask++, addr++) {
if ((*sa ^ *addr)  *mask) {
-   error = EINVAL;
 #ifdef DIAGNOSTIC
log(LOG_INFO, IPv4 address: \%s\ is not on 
the network\n,
inet_ntoa(((const struct sockaddr_in 
*)l3addr)-sin_addr));
 #endif
-   break;
+   RTFREE_LOCKED(rt);
+   return (EINVAL);
}
}
}
 
RTFREE_LOCKED(rt);
-   return (error);
+   return (0);
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226224 - head/sys/netinet

2011-10-10 Thread Gleb Smirnoff
  Qing,

On Mon, Oct 10, 2011 at 05:41:11PM +, Qing Li wrote:
Q Author: qingli
Q Date: Mon Oct 10 17:41:11 2011
Q New Revision: 226224
Q URL: http://svn.freebsd.org/changeset/base/226224
Q 
Q Log:
Q   All indirect routes will fail the rtcheck, except for a special host
Q   route where the destination IP and the gateway IP is the same. This
Q   special case handling is only meant for backward compatibility reason.
Q   The last commit introduced a bug in the route check logic, where a
Q   valid special case is treated as an error. This patch fixes that bug
Q   along with some code cleanup.
Q   
Q   Suggested by:  gleb
Q   Reviewed by:   kmacy, discussed with gleb
Q   MFC after: 1 day

  Looks like you have committed a slightly different patch to stable/8
in r226230. Is that okay?

  Also, you haven't awaited even one day, while our policy suggests at
least 3 days before MFC, and 3 days is actually a delay for critical
fixes.

P.S. Now I am not the only Gleb at FreeBSD.org community. Recently
Gleb Kurtsou joined us, and his login name is exactly gleb, while
mine is glebius. So, your commit may be confusing to later
reviewers of VCS history.

-- 
Totus tuus, Glebius.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226224 - head/sys/netinet

2011-10-10 Thread Qing Li
MFC 225946 is the original patch, 225947 messed up the logic a bit
while putting in the fix for another issue. 226224 is the fix to 225947,
which I will MFC tomorrow.

--Qing


2011/10/10 Gleb Smirnoff gleb...@freebsd.org:
  Qing,

 On Mon, Oct 10, 2011 at 05:41:11PM +, Qing Li wrote:
 Q Author: qingli
 Q Date: Mon Oct 10 17:41:11 2011
 Q New Revision: 226224
 Q URL: http://svn.freebsd.org/changeset/base/226224
 Q
 Q Log:
 Q   All indirect routes will fail the rtcheck, except for a special host
 Q   route where the destination IP and the gateway IP is the same. This
 Q   special case handling is only meant for backward compatibility reason.
 Q   The last commit introduced a bug in the route check logic, where a
 Q   valid special case is treated as an error. This patch fixes that bug
 Q   along with some code cleanup.
 Q
 Q   Suggested by:      gleb
 Q   Reviewed by:       kmacy, discussed with gleb
 Q   MFC after: 1 day

  Looks like you have committed a slightly different patch to stable/8
 in r226230. Is that okay?

  Also, you haven't awaited even one day, while our policy suggests at
 least 3 days before MFC, and 3 days is actually a delay for critical
 fixes.

 P.S. Now I am not the only Gleb at FreeBSD.org community. Recently
 Gleb Kurtsou joined us, and his login name is exactly gleb, while
 mine is glebius. So, your commit may be confusing to later
 reviewers of VCS history.

 --
 Totus tuus, Glebius.

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org