diff options
Diffstat (limited to 'include/net/inetpeer.h')
-rw-r--r-- | include/net/inetpeer.h | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index 599d96e74114..e6dd8da6b2ad 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h | |||
@@ -11,15 +11,20 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/jiffies.h> | 12 | #include <linux/jiffies.h> |
13 | #include <linux/spinlock.h> | 13 | #include <linux/spinlock.h> |
14 | #include <linux/rtnetlink.h> | ||
14 | #include <net/ipv6.h> | 15 | #include <net/ipv6.h> |
15 | #include <asm/atomic.h> | 16 | #include <asm/atomic.h> |
16 | 17 | ||
17 | struct inetpeer_addr { | 18 | struct inetpeer_addr_base { |
18 | union { | 19 | union { |
19 | __be32 a4; | 20 | __be32 a4; |
20 | __be32 a6[4]; | 21 | __be32 a6[4]; |
21 | }; | 22 | }; |
22 | __u16 family; | 23 | }; |
24 | |||
25 | struct inetpeer_addr { | ||
26 | struct inetpeer_addr_base addr; | ||
27 | __u16 family; | ||
23 | }; | 28 | }; |
24 | 29 | ||
25 | struct inet_peer { | 30 | struct inet_peer { |
@@ -33,15 +38,22 @@ struct inet_peer { | |||
33 | atomic_t refcnt; | 38 | atomic_t refcnt; |
34 | /* | 39 | /* |
35 | * Once inet_peer is queued for deletion (refcnt == -1), following fields | 40 | * Once inet_peer is queued for deletion (refcnt == -1), following fields |
36 | * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp | 41 | * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp, metrics |
37 | * We can share memory with rcu_head to keep inet_peer small | 42 | * We can share memory with rcu_head to help keep inet_peer small. |
38 | */ | 43 | */ |
39 | union { | 44 | union { |
40 | struct { | 45 | struct { |
41 | atomic_t rid; /* Frag reception counter */ | 46 | atomic_t rid; /* Frag reception counter */ |
42 | atomic_t ip_id_count; /* IP ID for the next packet */ | 47 | atomic_t ip_id_count; /* IP ID for the next packet */ |
43 | __u32 tcp_ts; | 48 | __u32 tcp_ts; |
44 | __u32 tcp_ts_stamp; | 49 | __u32 tcp_ts_stamp; |
50 | u32 metrics[RTAX_MAX]; | ||
51 | u32 rate_tokens; /* rate limiting for ICMP */ | ||
52 | unsigned long rate_last; | ||
53 | unsigned long pmtu_expires; | ||
54 | u32 pmtu_orig; | ||
55 | u32 pmtu_learned; | ||
56 | struct inetpeer_addr_base redirect_learned; | ||
45 | }; | 57 | }; |
46 | struct rcu_head rcu; | 58 | struct rcu_head rcu; |
47 | }; | 59 | }; |
@@ -49,6 +61,13 @@ struct inet_peer { | |||
49 | 61 | ||
50 | void inet_initpeers(void) __init; | 62 | void inet_initpeers(void) __init; |
51 | 63 | ||
64 | #define INETPEER_METRICS_NEW (~(u32) 0) | ||
65 | |||
66 | static inline bool inet_metrics_new(const struct inet_peer *p) | ||
67 | { | ||
68 | return p->metrics[RTAX_LOCK-1] == INETPEER_METRICS_NEW; | ||
69 | } | ||
70 | |||
52 | /* can be called with or without local BH being disabled */ | 71 | /* can be called with or without local BH being disabled */ |
53 | struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create); | 72 | struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create); |
54 | 73 | ||
@@ -56,7 +75,7 @@ static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create) | |||
56 | { | 75 | { |
57 | struct inetpeer_addr daddr; | 76 | struct inetpeer_addr daddr; |
58 | 77 | ||
59 | daddr.a4 = v4daddr; | 78 | daddr.addr.a4 = v4daddr; |
60 | daddr.family = AF_INET; | 79 | daddr.family = AF_INET; |
61 | return inet_getpeer(&daddr, create); | 80 | return inet_getpeer(&daddr, create); |
62 | } | 81 | } |
@@ -65,13 +84,14 @@ static inline struct inet_peer *inet_getpeer_v6(struct in6_addr *v6daddr, int cr | |||
65 | { | 84 | { |
66 | struct inetpeer_addr daddr; | 85 | struct inetpeer_addr daddr; |
67 | 86 | ||
68 | ipv6_addr_copy((struct in6_addr *)daddr.a6, v6daddr); | 87 | ipv6_addr_copy((struct in6_addr *)daddr.addr.a6, v6daddr); |
69 | daddr.family = AF_INET6; | 88 | daddr.family = AF_INET6; |
70 | return inet_getpeer(&daddr, create); | 89 | return inet_getpeer(&daddr, create); |
71 | } | 90 | } |
72 | 91 | ||
73 | /* can be called from BH context or outside */ | 92 | /* can be called from BH context or outside */ |
74 | extern void inet_putpeer(struct inet_peer *p); | 93 | extern void inet_putpeer(struct inet_peer *p); |
94 | extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout); | ||
75 | 95 | ||
76 | /* | 96 | /* |
77 | * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, | 97 | * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, |