udp: do not expect udp headers on ioctl SIOCINQ
[cascardo/linux.git] / net / ipv4 / udp.c
index d80312d..d2d294b 100644 (file)
@@ -604,6 +604,19 @@ static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
                                 udptable, skb);
 }
 
+struct sock *udp4_lib_lookup_skb(struct sk_buff *skb,
+                                __be16 sport, __be16 dport)
+{
+       const struct iphdr *iph = ip_hdr(skb);
+       const struct net_device *dev =
+           skb_dst(skb) ? skb_dst(skb)->dev : skb->dev;
+
+       return __udp4_lib_lookup(dev_net(dev), iph->saddr, sport,
+                                iph->daddr, dport, inet_iif(skb),
+                                &udp_table, skb);
+}
+EXPORT_SYMBOL_GPL(udp4_lib_lookup_skb);
+
 /* Must be called under rcu_read_lock().
  * Does increment socket refcount.
  */
@@ -1269,8 +1282,6 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
                         * of this packet since that is all
                         * that will be read.
                         */
-                       amount -= sizeof(struct udphdr);
-
                return put_user(amount, (int __user *)arg);
        }