ip6_fib.c (03351ff4d897098a590cb247b6eebc470b8ecb5a) | ip6_fib.c (e67f88dd12f610da98ca838822f2c9b4e7c6100e) |
---|---|
1/* 2 * Linux INET6 implementation 3 * Forwarding Information Database 4 * 5 * Authors: 6 * Pedro Roque <roque@di.fc.ul.pt> 7 * 8 * This program is free software; you can redistribute it and/or --- 120 unchanged lines hidden (view full) --- 129 * test bit 130 */ 131#if defined(__LITTLE_ENDIAN) 132# define BITOP_BE32_SWIZZLE (0x1F & ~7) 133#else 134# define BITOP_BE32_SWIZZLE 0 135#endif 136 | 1/* 2 * Linux INET6 implementation 3 * Forwarding Information Database 4 * 5 * Authors: 6 * Pedro Roque <roque@di.fc.ul.pt> 7 * 8 * This program is free software; you can redistribute it and/or --- 120 unchanged lines hidden (view full) --- 129 * test bit 130 */ 131#if defined(__LITTLE_ENDIAN) 132# define BITOP_BE32_SWIZZLE (0x1F & ~7) 133#else 134# define BITOP_BE32_SWIZZLE 0 135#endif 136 |
137static __inline__ __be32 addr_bit_set(void *token, int fn_bit) | 137static __inline__ __be32 addr_bit_set(const void *token, int fn_bit) |
138{ | 138{ |
139 __be32 *addr = token; | 139 const __be32 *addr = token; |
140 /* 141 * Here, 142 * 1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f) 143 * is optimized version of 144 * htonl(1 << ((~fn_bit)&0x1F)) 145 * See include/asm-generic/bitops/le.h. 146 */ 147 return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) & --- 241 unchanged lines hidden (view full) --- 389 cb->args[2] = (long)w; 390 } 391 392 arg.skb = skb; 393 arg.cb = cb; 394 arg.net = net; 395 w->args = &arg; 396 | 140 /* 141 * Here, 142 * 1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f) 143 * is optimized version of 144 * htonl(1 << ((~fn_bit)&0x1F)) 145 * See include/asm-generic/bitops/le.h. 146 */ 147 return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) & --- 241 unchanged lines hidden (view full) --- 389 cb->args[2] = (long)w; 390 } 391 392 arg.skb = skb; 393 arg.cb = cb; 394 arg.net = net; 395 w->args = &arg; 396 |
397 rcu_read_lock(); |
|
397 for (h = s_h; h < FIB6_TABLE_HASHSZ; h++, s_e = 0) { 398 e = 0; 399 head = &net->ipv6.fib_table_hash[h]; | 398 for (h = s_h; h < FIB6_TABLE_HASHSZ; h++, s_e = 0) { 399 e = 0; 400 head = &net->ipv6.fib_table_hash[h]; |
400 hlist_for_each_entry(tb, node, head, tb6_hlist) { | 401 hlist_for_each_entry_rcu(tb, node, head, tb6_hlist) { |
401 if (e < s_e) 402 goto next; 403 res = fib6_dump_table(tb, skb, cb); 404 if (res != 0) 405 goto out; 406next: 407 e++; 408 } 409 } 410out: | 402 if (e < s_e) 403 goto next; 404 res = fib6_dump_table(tb, skb, cb); 405 if (res != 0) 406 goto out; 407next: 408 e++; 409 } 410 } 411out: |
412 rcu_read_unlock(); |
|
411 cb->args[1] = e; 412 cb->args[0] = h; 413 414 res = res < 0 ? res : skb->len; 415 if (res <= 0) 416 fib6_dump_end(cb); 417 return res; 418} --- 398 unchanged lines hidden (view full) --- 817 818/* 819 * Routing tree lookup 820 * 821 */ 822 823struct lookup_args { 824 int offset; /* key offset on rt6_info */ | 413 cb->args[1] = e; 414 cb->args[0] = h; 415 416 res = res < 0 ? res : skb->len; 417 if (res <= 0) 418 fib6_dump_end(cb); 419 return res; 420} --- 398 unchanged lines hidden (view full) --- 819 820/* 821 * Routing tree lookup 822 * 823 */ 824 825struct lookup_args { 826 int offset; /* key offset on rt6_info */ |
825 struct in6_addr *addr; /* search key */ | 827 const struct in6_addr *addr; /* search key */ |
826}; 827 828static struct fib6_node * fib6_lookup_1(struct fib6_node *root, 829 struct lookup_args *args) 830{ 831 struct fib6_node *fn; 832 __be32 dir; 833 --- 42 unchanged lines hidden (view full) --- 876 break; 877 878 fn = fn->parent; 879 } 880 881 return NULL; 882} 883 | 828}; 829 830static struct fib6_node * fib6_lookup_1(struct fib6_node *root, 831 struct lookup_args *args) 832{ 833 struct fib6_node *fn; 834 __be32 dir; 835 --- 42 unchanged lines hidden (view full) --- 878 break; 879 880 fn = fn->parent; 881 } 882 883 return NULL; 884} 885 |
884struct fib6_node * fib6_lookup(struct fib6_node *root, struct in6_addr *daddr, 885 struct in6_addr *saddr) | 886struct fib6_node * fib6_lookup(struct fib6_node *root, const struct in6_addr *daddr, 887 const struct in6_addr *saddr) |
886{ 887 struct fib6_node *fn; 888 struct lookup_args args[] = { 889 { 890 .offset = offsetof(struct rt6_info, rt6i_dst), 891 .addr = daddr, 892 }, 893#ifdef CONFIG_IPV6_SUBTREES --- 17 unchanged lines hidden (view full) --- 911 912/* 913 * Get node with specified destination prefix (and source prefix, 914 * if subtrees are used) 915 */ 916 917 918static struct fib6_node * fib6_locate_1(struct fib6_node *root, | 888{ 889 struct fib6_node *fn; 890 struct lookup_args args[] = { 891 { 892 .offset = offsetof(struct rt6_info, rt6i_dst), 893 .addr = daddr, 894 }, 895#ifdef CONFIG_IPV6_SUBTREES --- 17 unchanged lines hidden (view full) --- 913 914/* 915 * Get node with specified destination prefix (and source prefix, 916 * if subtrees are used) 917 */ 918 919 920static struct fib6_node * fib6_locate_1(struct fib6_node *root, |
919 struct in6_addr *addr, | 921 const struct in6_addr *addr, |
920 int plen, int offset) 921{ 922 struct fib6_node *fn; 923 924 for (fn = root; fn ; ) { 925 struct rt6key *key = (struct rt6key *)((u8 *)fn->leaf + offset); 926 927 /* --- 13 unchanged lines hidden (view full) --- 941 fn = fn->right; 942 else 943 fn = fn->left; 944 } 945 return NULL; 946} 947 948struct fib6_node * fib6_locate(struct fib6_node *root, | 922 int plen, int offset) 923{ 924 struct fib6_node *fn; 925 926 for (fn = root; fn ; ) { 927 struct rt6key *key = (struct rt6key *)((u8 *)fn->leaf + offset); 928 929 /* --- 13 unchanged lines hidden (view full) --- 943 fn = fn->right; 944 else 945 fn = fn->left; 946 } 947 return NULL; 948} 949 950struct fib6_node * fib6_locate(struct fib6_node *root, |
949 struct in6_addr *daddr, int dst_len, 950 struct in6_addr *saddr, int src_len) | 951 const struct in6_addr *daddr, int dst_len, 952 const struct in6_addr *saddr, int src_len) |
951{ 952 struct fib6_node *fn; 953 954 fn = fib6_locate_1(root, daddr, dst_len, 955 offsetof(struct rt6_info, rt6i_dst)); 956 957#ifdef CONFIG_IPV6_SUBTREES 958 if (src_len) { --- 646 unchanged lines hidden --- | 953{ 954 struct fib6_node *fn; 955 956 fn = fib6_locate_1(root, daddr, dst_len, 957 offsetof(struct rt6_info, rt6i_dst)); 958 959#ifdef CONFIG_IPV6_SUBTREES 960 if (src_len) { --- 646 unchanged lines hidden --- |