Forráskód Böngészése

[IPV4]: inetpeer annotations

This one is interesting - we use net-endian value as search key, but
order the tree by *host-endian* comparisons of keys.  OK since we only
care about lookups.  Annotated inet_getpeer() and friends.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Al Viro 18 éve
szülő
commit
53576d9b99
2 módosított fájl, 4 hozzáadás és 4 törlés
  1. 2 2
      include/net/inetpeer.h
  2. 2 2
      net/ipv4/inetpeer.c

+ 2 - 2
include/net/inetpeer.h

@@ -22,7 +22,7 @@ struct inet_peer
 	unsigned long		dtime;		/* the time of last use of not
 	unsigned long		dtime;		/* the time of last use of not
 						 * referenced entries */
 						 * referenced entries */
 	atomic_t		refcnt;
 	atomic_t		refcnt;
-	__u32			v4daddr;	/* peer's address */
+	__be32			v4daddr;	/* peer's address */
 	__u16			avl_height;
 	__u16			avl_height;
 	__u16			ip_id_count;	/* IP ID for the next packet */
 	__u16			ip_id_count;	/* IP ID for the next packet */
 	atomic_t		rid;		/* Frag reception counter */
 	atomic_t		rid;		/* Frag reception counter */
@@ -33,7 +33,7 @@ struct inet_peer
 void			inet_initpeers(void) __init;
 void			inet_initpeers(void) __init;
 
 
 /* can be called with or without local BH being disabled */
 /* can be called with or without local BH being disabled */
-struct inet_peer	*inet_getpeer(__u32 daddr, int create);
+struct inet_peer	*inet_getpeer(__be32 daddr, int create);
 
 
 extern spinlock_t inet_peer_unused_lock;
 extern spinlock_t inet_peer_unused_lock;
 extern struct inet_peer **inet_peer_unused_tailp;
 extern struct inet_peer **inet_peer_unused_tailp;

+ 2 - 2
net/ipv4/inetpeer.c

@@ -163,7 +163,7 @@ static void unlink_from_unused(struct inet_peer *p)
 	for (u = peer_root; u != peer_avl_empty; ) {		\
 	for (u = peer_root; u != peer_avl_empty; ) {		\
 		if (daddr == u->v4daddr)			\
 		if (daddr == u->v4daddr)			\
 			break;					\
 			break;					\
-		if (daddr < u->v4daddr)				\
+		if ((__force __u32)daddr < (__force __u32)u->v4daddr)	\
 			v = &u->avl_left;			\
 			v = &u->avl_left;			\
 		else						\
 		else						\
 			v = &u->avl_right;			\
 			v = &u->avl_right;			\
@@ -368,7 +368,7 @@ static int cleanup_once(unsigned long ttl)
 }
 }
 
 
 /* Called with or without local BH being disabled. */
 /* Called with or without local BH being disabled. */
-struct inet_peer *inet_getpeer(__u32 daddr, int create)
+struct inet_peer *inet_getpeer(__be32 daddr, int create)
 {
 {
 	struct inet_peer *p, *n;
 	struct inet_peer *p, *n;
 	struct inet_peer **stack[PEER_MAXDEPTH], ***stackptr;
 	struct inet_peer **stack[PEER_MAXDEPTH], ***stackptr;