Skip to content

Commit 721a57a

Browse files
committed
Merge branch 'tipc-next'
Erik Hugne says: ==================== tipc: bug fix and some improvements Most important is a fix for a nullptr exception that would occur when name table subscriptions fail. The remaining patches are performance improvements and cosmetic changes. v2: remove unnecessary whitespace in patch #2 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 247f6d0 + d76a436 commit 721a57a

File tree

7 files changed

+15
-31
lines changed

7 files changed

+15
-31
lines changed

net/tipc/bearer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
742742
return -EINVAL;
743743
}
744744

745-
bearer_disable(net, bearer, false);
745+
bearer_disable(net, bearer, true);
746746
rtnl_unlock();
747747

748748
return 0;

net/tipc/bearer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@
5050
* - the field's actual content and length is defined per media
5151
* - remaining unused bytes in the field are set to zero
5252
*/
53-
#define TIPC_MEDIA_ADDR_SIZE 32
53+
#define TIPC_MEDIA_INFO_SIZE 32
5454
#define TIPC_MEDIA_TYPE_OFFSET 3
55+
#define TIPC_MEDIA_ADDR_OFFSET 4
5556

5657
/*
5758
* Identifiers of supported TIPC media types
@@ -76,7 +77,7 @@ struct tipc_node_map {
7677
* @broadcast: non-zero if address is a broadcast address
7778
*/
7879
struct tipc_media_addr {
79-
u8 value[TIPC_MEDIA_ADDR_SIZE];
80+
u8 value[TIPC_MEDIA_INFO_SIZE];
8081
u8 media_id;
8182
u8 broadcast;
8283
};

net/tipc/eth_media.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "core.h"
3838
#include "bearer.h"
3939

40-
#define ETH_ADDR_OFFSET 4 /* MAC addr position inside address field */
41-
4240
/* Convert Ethernet address (media address format) to string */
4341
static int tipc_eth_addr2str(struct tipc_media_addr *addr,
4442
char *strbuf, int bufsz)
@@ -53,9 +51,9 @@ static int tipc_eth_addr2str(struct tipc_media_addr *addr,
5351
/* Convert from media address format to discovery message addr format */
5452
static int tipc_eth_addr2msg(char *msg, struct tipc_media_addr *addr)
5553
{
56-
memset(msg, 0, TIPC_MEDIA_ADDR_SIZE);
54+
memset(msg, 0, TIPC_MEDIA_INFO_SIZE);
5755
msg[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH;
58-
memcpy(msg + ETH_ADDR_OFFSET, addr->value, ETH_ALEN);
56+
memcpy(msg + TIPC_MEDIA_ADDR_OFFSET, addr->value, ETH_ALEN);
5957
return 0;
6058
}
6159

@@ -79,7 +77,7 @@ static int tipc_eth_msg2addr(struct tipc_bearer *b,
7977
char *msg)
8078
{
8179
/* Skip past preamble: */
82-
msg += ETH_ADDR_OFFSET;
80+
msg += TIPC_MEDIA_ADDR_OFFSET;
8381
return tipc_eth_raw2addr(b, addr, msg);
8482
}
8583

net/tipc/ib_media.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int tipc_ib_addr2str(struct tipc_media_addr *a, char *str_buf,
5757
/* Convert from media address format to discovery message addr format */
5858
static int tipc_ib_addr2msg(char *msg, struct tipc_media_addr *addr)
5959
{
60-
memset(msg, 0, TIPC_MEDIA_ADDR_SIZE);
60+
memset(msg, 0, TIPC_MEDIA_INFO_SIZE);
6161
memcpy(msg, addr->value, INFINIBAND_ALEN);
6262
return 0;
6363
}

net/tipc/msg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct plist;
7676

7777
#define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
7878

79-
#define TIPC_MEDIA_ADDR_OFFSET 5
79+
#define TIPC_MEDIA_INFO_OFFSET 5
8080

8181
/**
8282
* TIPC message buffer code
@@ -688,7 +688,7 @@ static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r)
688688

689689
static inline char *msg_media_addr(struct tipc_msg *m)
690690
{
691-
return (char *)&m->hdr[TIPC_MEDIA_ADDR_OFFSET];
691+
return (char *)&m->hdr[TIPC_MEDIA_INFO_OFFSET];
692692
}
693693

694694
/*

net/tipc/name_distr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void named_cluster_distribute(struct net *net, struct sk_buff *skb)
9898
continue;
9999
if (!tipc_node_active_links(node))
100100
continue;
101-
oskb = skb_copy(skb, GFP_ATOMIC);
101+
oskb = pskb_copy(skb, GFP_ATOMIC);
102102
if (!oskb)
103103
break;
104104
msg_set_destnode(buf_msg(oskb), dnode);

net/tipc/subscr.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,6 @@ static void subscr_del(struct tipc_subscription *sub)
162162
atomic_dec(&tn->subscription_count);
163163
}
164164

165-
/**
166-
* subscr_terminate - terminate communication with a subscriber
167-
*
168-
* Note: Must call it in process context since it might sleep.
169-
*/
170-
static void subscr_terminate(struct tipc_subscription *sub)
171-
{
172-
struct tipc_subscriber *subscriber = sub->subscriber;
173-
struct tipc_net *tn = net_generic(sub->net, tipc_net_id);
174-
175-
tipc_conn_terminate(tn->topsrv, subscriber->conid);
176-
}
177-
178165
static void subscr_release(struct tipc_subscriber *subscriber)
179166
{
180167
struct tipc_subscription *sub;
@@ -312,16 +299,14 @@ static void subscr_conn_msg_event(struct net *net, int conid,
312299
{
313300
struct tipc_subscriber *subscriber = usr_data;
314301
struct tipc_subscription *sub = NULL;
302+
struct tipc_net *tn = net_generic(net, tipc_net_id);
315303

316304
spin_lock_bh(&subscriber->lock);
317-
if (subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber,
318-
&sub) < 0) {
319-
spin_unlock_bh(&subscriber->lock);
320-
subscr_terminate(sub);
321-
return;
322-
}
305+
subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber, &sub);
323306
if (sub)
324307
tipc_nametbl_subscribe(sub);
308+
else
309+
tipc_conn_terminate(tn->topsrv, subscriber->conid);
325310
spin_unlock_bh(&subscriber->lock);
326311
}
327312

0 commit comments

Comments
 (0)