inetpeer: get rid of ip_id_count
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / net / ip.h
index a68f838a132c522df397b9398f8f2d64646008c0..dd72c8f937979890d4544157d3ebe8f76be7ddae 100644 (file)
@@ -252,32 +252,42 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
                 !(dst_metric_locked(dst, RTAX_MTU)));
 }
 
-extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
+#define IP_IDENTS_SZ 2048u
+extern atomic_t *ip_idents;
 
-static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk)
+static inline u32 ip_idents_reserve(u32 hash, int segs)
 {
-       if (iph->frag_off & htons(IP_DF)) {
+       atomic_t *id_ptr = ip_idents + hash % IP_IDENTS_SZ;
+
+       return atomic_add_return(segs, id_ptr) - segs;
+}
+
+void __ip_select_ident(struct iphdr *iph, int segs);
+
+static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, int segs)
+{
+       struct iphdr *iph = ip_hdr(skb);
+
+       if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
                /* This is only to work around buggy Windows95/2000
                 * VJ compression implementations.  If the ID field
                 * does not change, they drop every other packet in
                 * a TCP stream using header compression.
                 */
-               iph->id = (sk && inet_sk(sk)->inet_daddr) ?
-                                       htons(inet_sk(sk)->inet_id++) : 0;
-       } else
-               __ip_select_ident(iph, dst, 0);
-}
-
-static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more)
-{
-       if (iph->frag_off & htons(IP_DF)) {
                if (sk && inet_sk(sk)->inet_daddr) {
                        iph->id = htons(inet_sk(sk)->inet_id);
-                       inet_sk(sk)->inet_id += 1 + more;
-               } else
+                       inet_sk(sk)->inet_id += segs;
+               } else {
                        iph->id = 0;
-       } else
-               __ip_select_ident(iph, dst, more);
+               }
+       } else {
+               __ip_select_ident(iph, segs);
+       }
+}
+
+static inline void ip_select_ident(struct sk_buff *skb, struct sock *sk)
+{
+       ip_select_ident_segs(skb, sk, 1);
 }
 
 /*
@@ -450,7 +460,7 @@ extern int  compat_ip_getsockopt(struct sock *sk, int level,
                        int optname, char __user *optval, int __user *optlen);
 extern int     ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *));
 
-extern int     ip_recv_error(struct sock *sk, struct msghdr *msg, int len);
+extern int     ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len);
 extern void    ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 
                              __be16 port, u32 info, u8 *payload);
 extern void    ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,