Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / net / bluetooth / bnep / core.c
index ce7b9a5..d908d49 100644 (file)
@@ -61,7 +61,7 @@
 #define BT_DBG(D...)
 #endif
 
-#define VERSION "1.0"
+#define VERSION "1.2"
 
 static LIST_HEAD(bnep_session_list);
 static DECLARE_RWSEM(bnep_session_sem);
@@ -75,7 +75,7 @@ static struct bnep_session *__bnep_get_session(u8 *dst)
 
        list_for_each(p, &bnep_session_list) {
                s = list_entry(p, struct bnep_session, list);   
-               if (!memcmp(dst, s->eh.h_source, ETH_ALEN))
+               if (!compare_ether_addr(dst, s->eh.h_source))
                        return s;
        }
        return NULL;
@@ -99,11 +99,9 @@ static void __bnep_unlink_session(struct bnep_session *s)
 static int bnep_send(struct bnep_session *s, void *data, size_t len)
 {
        struct socket *sock = s->sock;
-       struct iovec iv = { data, len };
+       struct kvec iv = { data, len };
 
-       s->msg.msg_iov    = &iv;
-       s->msg.msg_iovlen = 1;
-       return sock_sendmsg(sock, &s->msg, len);
+       return kernel_sendmsg(sock, &s->msg, &iv, 1, len);
 }
 
 static int bnep_send_rsp(struct bnep_session *s, u8 ctrl, u16 resp)
@@ -115,6 +113,21 @@ static int bnep_send_rsp(struct bnep_session *s, u8 ctrl, u16 resp)
        return bnep_send(s, &rsp, sizeof(rsp));
 }
 
+#ifdef CONFIG_BT_BNEP_PROTO_FILTER
+static inline void bnep_set_default_proto_filter(struct bnep_session *s)
+{
+       /* (IPv4, ARP)  */
+       s->proto_filter[0].start = htons(0x0800);
+       s->proto_filter[0].end   = htons(0x0806);
+       /* (RARP, AppleTalk) */
+       s->proto_filter[1].start = htons(0x8035);
+       s->proto_filter[1].end   = htons(0x80F3);
+       /* (IPX, IPv6) */
+       s->proto_filter[2].start = htons(0x8137);
+       s->proto_filter[2].end   = htons(0x86DD);
+}
+#endif
+
 static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len)
 {
        int n;
@@ -143,9 +156,13 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len)
                        BT_DBG("proto filter start %d end %d",
                                f[i].start, f[i].end);
                }
+
                if (i < BNEP_MAX_PROTO_FILTERS)
                        memset(f + i, 0, sizeof(*f));
 
+               if (n == 0)
+                       bnep_set_default_proto_filter(s);
+
                bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_SUCCESS);
        } else {
                bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_LIMIT_REACHED);
@@ -367,7 +384,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
        
        s->stats.rx_packets++;
        nskb->dev       = dev;
-       nskb->ip_summed = CHECKSUM_UNNECESSARY;
+       nskb->ip_summed = CHECKSUM_NONE;
        nskb->protocol  = eth_type_trans(nskb, dev);
        netif_rx_ni(nskb);
        return 0;
@@ -389,7 +406,7 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
 {
        struct ethhdr *eh = (void *) skb->data;
        struct socket *sock = s->sock;
-       struct iovec iv[3];
+       struct kvec iv[3];
        int len = 0, il = 0;
        u8 type = 0;
 
@@ -400,13 +417,13 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
                goto send;
        }
 
-       iv[il++] = (struct iovec) { &type, 1 };
+       iv[il++] = (struct kvec) { &type, 1 };
        len++;
 
-       if (!memcmp(eh->h_dest, s->eh.h_source, ETH_ALEN))
+       if (!compare_ether_addr(eh->h_dest, s->eh.h_source))
                type |= 0x01;
 
-       if (!memcmp(eh->h_source, s->eh.h_dest, ETH_ALEN))
+       if (!compare_ether_addr(eh->h_source, s->eh.h_dest))
                type |= 0x02;
 
        if (type)
@@ -415,25 +432,23 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
        type = __bnep_tx_types[type];
        switch (type) {
        case BNEP_COMPRESSED_SRC_ONLY:
-               iv[il++] = (struct iovec) { eh->h_source, ETH_ALEN };
+               iv[il++] = (struct kvec) { eh->h_source, ETH_ALEN };
                len += ETH_ALEN;
                break;
                
        case BNEP_COMPRESSED_DST_ONLY:
-               iv[il++] = (struct iovec) { eh->h_dest, ETH_ALEN };
+               iv[il++] = (struct kvec) { eh->h_dest, ETH_ALEN };
                len += ETH_ALEN;
                break;
        }
 
 send:
-       iv[il++] = (struct iovec) { skb->data, skb->len };
+       iv[il++] = (struct kvec) { skb->data, skb->len };
        len += skb->len;
        
        /* FIXME: linearize skb */
        {
-               s->msg.msg_iov    = iv;
-               s->msg.msg_iovlen = il;
-               len = sock_sendmsg(sock, &s->msg, len);
+               len = kernel_sendmsg(sock, &s->msg, iv, il, len);
        }
        kfree_skb(skb);
 
@@ -460,8 +475,6 @@ static int bnep_session(void *arg)
        set_user_nice(current, -15);
        current->flags |= PF_NOFREEZE;
 
-        set_fs(KERNEL_DS);
-
        init_waitqueue_entry(&wait, current);
        add_wait_queue(sk->sk_sleep, &wait);
        while (!atomic_read(&s->killed)) {
@@ -519,8 +532,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
        dev = alloc_netdev(sizeof(struct bnep_session),
                           (*req->device) ? req->device : "bnep%d",
                           bnep_net_setup);
-       if (!dev) 
-               return ENOMEM;
+       if (!dev)
+               return -ENOMEM;
 
 
        down_write(&bnep_session_sem);
@@ -550,21 +563,12 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
        /* Set default mc filter */
        set_bit(bnep_mc_hash(dev->broadcast), (ulong *) &s->mc_filter);
 #endif
-       
+
 #ifdef CONFIG_BT_BNEP_PROTO_FILTER
        /* Set default protocol filter */
-
-       /* (IPv4, ARP)  */
-       s->proto_filter[0].start = htons(0x0800);
-       s->proto_filter[0].end   = htons(0x0806);
-       /* (RARP, AppleTalk) */
-       s->proto_filter[1].start = htons(0x8035);
-       s->proto_filter[1].end   = htons(0x80F3);
-       /* (IPX, IPv6) */
-       s->proto_filter[2].start = htons(0x8137);
-       s->proto_filter[2].end   = htons(0x86DD);
+       bnep_set_default_proto_filter(s);
 #endif
-       
+
        err = register_netdev(dev);
        if (err) {
                goto failed;