tipc: move linearization of buffers to generic code
authorJon Paul Maloy <jon.maloy@ericsson.com>
Wed, 21 Sep 2016 13:00:02 +0000 (15:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Sep 2016 08:07:35 +0000 (10:07 +0200)
commit c7cad0d6f70cd4ce8644ffe528a4df1cdc2e77f5 upstream.

In commit 5cbb28a4bf65c7e4 ("tipc: linearize arriving NAME_DISTR
and LINK_PROTO buffers") we added linearization of NAME_DISTRIBUTOR,
LINK_PROTOCOL/RESET and LINK_PROTOCOL/ACTIVATE to the function
tipc_udp_recv(). The location of the change was selected in order
to make the commit easily appliable to 'net' and 'stable'.

We now move this linearization to where it should be done, in the
functions tipc_named_rcv() and tipc_link_proto_rcv() respectively.

Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Juerg Haefliger <juerg.haefliger@hpe.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tipc/link.c
net/tipc/name_distr.c
net/tipc/udp_media.c

index 91aea071ab27fee550e3c88ecc4097adac399d83..72268eac4ec7237787f53f2dadf886325f8e5cf6 100644 (file)
@@ -1262,6 +1262,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
                /* fall thru' */
 
        case ACTIVATE_MSG:
+               skb_linearize(skb);
+               hdr = buf_msg(skb);
 
                /* Complete own link name with peer's interface name */
                if_name =  strrchr(l->name, ':') + 1;
index c07612bab95c0957b2e34434aa73b6ef02708fff..f51c8bdbea1c010a6f6405932c2d3e1144f75219 100644 (file)
@@ -397,6 +397,7 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq)
 
        spin_lock_bh(&tn->nametbl_lock);
        for (skb = skb_dequeue(inputq); skb; skb = skb_dequeue(inputq)) {
+               skb_linearize(skb);
                msg = buf_msg(skb);
                mtype = msg_type(msg);
                item = (struct distr_item *)msg_data(msg);
index 70c03271b798f429d8d6faa5142fb2654753d342..6af78c6276b4b185be00d62370932bb1d816bfd4 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/tipc_netlink.h>
 #include "core.h"
 #include "bearer.h"
-#include "msg.h"
 
 /* IANA assigned UDP port */
 #define UDP_PORT_DEFAULT       6118
@@ -224,10 +223,6 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb)
 {
        struct udp_bearer *ub;
        struct tipc_bearer *b;
-       int usr = msg_user(buf_msg(skb));
-
-       if ((usr == LINK_PROTOCOL) || (usr == NAME_DISTRIBUTOR))
-               skb_linearize(skb);
 
        ub = rcu_dereference_sk_user_data(sk);
        if (!ub) {