提交 b55b10be 编写于 作者: D David S. Miller

Merge branch 'tipc-next'

Jon Maloy says:

====================
tipc: some link layer improvements

We continue eliminating redundant complexity at the link layer, and
add a couple of improvements to the packet sending functionality.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -38,13 +38,6 @@ ...@@ -38,13 +38,6 @@
#include "addr.h" #include "addr.h"
#include "core.h" #include "core.h"
u32 tipc_own_addr(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
return tn->own_addr;
}
/** /**
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches * in_own_cluster - test for cluster inclusion; <0.0.0> always matches
*/ */
......
...@@ -41,10 +41,18 @@ ...@@ -41,10 +41,18 @@
#include <linux/tipc.h> #include <linux/tipc.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include "core.h"
#define TIPC_ZONE_MASK 0xff000000u #define TIPC_ZONE_MASK 0xff000000u
#define TIPC_CLUSTER_MASK 0xfffff000u #define TIPC_CLUSTER_MASK 0xfffff000u
static inline u32 tipc_own_addr(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
return tn->own_addr;
}
static inline u32 tipc_zone_mask(u32 addr) static inline u32 tipc_zone_mask(u32 addr)
{ {
return addr & TIPC_ZONE_MASK; return addr & TIPC_ZONE_MASK;
......
...@@ -115,19 +115,15 @@ static void bclink_set_last_sent(struct net *net) ...@@ -115,19 +115,15 @@ static void bclink_set_last_sent(struct net *net)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_link *bcl = tn->bcl; struct tipc_link *bcl = tn->bcl;
struct sk_buff *skb = skb_peek(&bcl->backlogq);
if (skb) bcl->silent_intv_cnt = mod(bcl->snd_nxt - 1);
bcl->fsm_msg_cnt = mod(buf_seqno(skb) - 1);
else
bcl->fsm_msg_cnt = mod(bcl->next_out_no - 1);
} }
u32 tipc_bclink_get_last_sent(struct net *net) u32 tipc_bclink_get_last_sent(struct net *net)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
return tn->bcl->fsm_msg_cnt; return tn->bcl->silent_intv_cnt;
} }
static void bclink_update_last_sent(struct tipc_node *node, u32 seqno) static void bclink_update_last_sent(struct tipc_node *node, u32 seqno)
...@@ -212,16 +208,16 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) ...@@ -212,16 +208,16 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
* or both sent and unsent messages (otherwise) * or both sent and unsent messages (otherwise)
*/ */
if (tn->bclink->bcast_nodes.count) if (tn->bclink->bcast_nodes.count)
acked = tn->bcl->fsm_msg_cnt; acked = tn->bcl->silent_intv_cnt;
else else
acked = tn->bcl->next_out_no; acked = tn->bcl->snd_nxt;
} else { } else {
/* /*
* Bail out if specified sequence number does not correspond * Bail out if specified sequence number does not correspond
* to a message that has been sent and not yet acknowledged * to a message that has been sent and not yet acknowledged
*/ */
if (less(acked, buf_seqno(skb)) || if (less(acked, buf_seqno(skb)) ||
less(tn->bcl->fsm_msg_cnt, acked) || less(tn->bcl->silent_intv_cnt, acked) ||
less_eq(acked, n_ptr->bclink.acked)) less_eq(acked, n_ptr->bclink.acked))
goto exit; goto exit;
} }
...@@ -803,9 +799,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) ...@@ -803,9 +799,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
goto attr_msg_full; goto attr_msg_full;
if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name))
goto attr_msg_full; goto attr_msg_full;
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->next_in_no)) if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt))
goto attr_msg_full; goto attr_msg_full;
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->next_out_no)) if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt))
goto attr_msg_full; goto attr_msg_full;
prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
...@@ -914,7 +910,7 @@ int tipc_bclink_init(struct net *net) ...@@ -914,7 +910,7 @@ int tipc_bclink_init(struct net *net)
__skb_queue_head_init(&bcl->backlogq); __skb_queue_head_init(&bcl->backlogq);
__skb_queue_head_init(&bcl->deferdq); __skb_queue_head_init(&bcl->deferdq);
skb_queue_head_init(&bcl->wakeupq); skb_queue_head_init(&bcl->wakeupq);
bcl->next_out_no = 1; bcl->snd_nxt = 1;
spin_lock_init(&bclink->node.lock); spin_lock_init(&bclink->node.lock);
__skb_queue_head_init(&bclink->arrvq); __skb_queue_head_init(&bclink->arrvq);
skb_queue_head_init(&bclink->inputq); skb_queue_head_init(&bclink->inputq);
......
...@@ -71,8 +71,7 @@ static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = { ...@@ -71,8 +71,7 @@ static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
[TIPC_NLA_MEDIA_PROP] = { .type = NLA_NESTED } [TIPC_NLA_MEDIA_PROP] = { .type = NLA_NESTED }
}; };
static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr, static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr);
bool shutting_down);
/** /**
* tipc_media_find - locates specified media object by name * tipc_media_find - locates specified media object by name
...@@ -324,7 +323,7 @@ static int tipc_enable_bearer(struct net *net, const char *name, ...@@ -324,7 +323,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
res = tipc_disc_create(net, b_ptr, &b_ptr->bcast_addr); res = tipc_disc_create(net, b_ptr, &b_ptr->bcast_addr);
if (res) { if (res) {
bearer_disable(net, b_ptr, false); bearer_disable(net, b_ptr);
pr_warn("Bearer <%s> rejected, discovery object creation failed\n", pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
name); name);
return -EINVAL; return -EINVAL;
...@@ -344,7 +343,7 @@ static int tipc_enable_bearer(struct net *net, const char *name, ...@@ -344,7 +343,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr)
{ {
pr_info("Resetting bearer <%s>\n", b_ptr->name); pr_info("Resetting bearer <%s>\n", b_ptr->name);
tipc_link_reset_list(net, b_ptr->identity); tipc_link_delete_list(net, b_ptr->identity);
tipc_disc_reset(net, b_ptr); tipc_disc_reset(net, b_ptr);
return 0; return 0;
} }
...@@ -354,8 +353,7 @@ static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) ...@@ -354,8 +353,7 @@ static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr)
* *
* Note: This routine assumes caller holds RTNL lock. * Note: This routine assumes caller holds RTNL lock.
*/ */
static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr, static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr)
bool shutting_down)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
u32 i; u32 i;
...@@ -363,7 +361,7 @@ static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr, ...@@ -363,7 +361,7 @@ static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr,
pr_info("Disabling bearer <%s>\n", b_ptr->name); pr_info("Disabling bearer <%s>\n", b_ptr->name);
b_ptr->media->disable_media(b_ptr); b_ptr->media->disable_media(b_ptr);
tipc_link_delete_list(net, b_ptr->identity, shutting_down); tipc_link_delete_list(net, b_ptr->identity);
if (b_ptr->link_req) if (b_ptr->link_req)
tipc_disc_delete(b_ptr->link_req); tipc_disc_delete(b_ptr->link_req);
...@@ -541,7 +539,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, ...@@ -541,7 +539,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
bearer_disable(dev_net(dev), b_ptr, false); bearer_disable(dev_net(dev), b_ptr);
break; break;
} }
return NOTIFY_OK; return NOTIFY_OK;
...@@ -583,7 +581,7 @@ void tipc_bearer_stop(struct net *net) ...@@ -583,7 +581,7 @@ void tipc_bearer_stop(struct net *net)
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
b_ptr = rtnl_dereference(tn->bearer_list[i]); b_ptr = rtnl_dereference(tn->bearer_list[i]);
if (b_ptr) { if (b_ptr) {
bearer_disable(net, b_ptr, true); bearer_disable(net, b_ptr);
tn->bearer_list[i] = NULL; tn->bearer_list[i] = NULL;
} }
} }
...@@ -747,7 +745,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) ...@@ -747,7 +745,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
return -EINVAL; return -EINVAL;
} }
bearer_disable(net, bearer, false); bearer_disable(net, bearer);
rtnl_unlock(); rtnl_unlock();
return 0; return 0;
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
#define _TIPC_BEARER_H #define _TIPC_BEARER_H
#include "netlink.h" #include "netlink.h"
#include "core.h"
#include <net/genetlink.h> #include <net/genetlink.h>
#define MAX_BEARERS 2
#define MAX_MEDIA 3 #define MAX_MEDIA 3
#define MAX_NODES 4096 #define MAX_NODES 4096
#define WSIZE 32 #define WSIZE 32
......
...@@ -60,16 +60,19 @@ ...@@ -60,16 +60,19 @@
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include <linux/rhashtable.h> #include <linux/rhashtable.h>
#include "node.h" struct tipc_node;
#include "bearer.h" struct tipc_bearer;
#include "bcast.h" struct tipc_bcbearer;
#include "netlink.h" struct tipc_bclink;
#include "link.h" struct tipc_link;
#include "node.h" struct tipc_name_table;
#include "msg.h" struct tipc_server;
#define TIPC_MOD_VER "2.0.0" #define TIPC_MOD_VER "2.0.0"
#define NODE_HTABLE_SIZE 512
#define MAX_BEARERS 3
extern int tipc_net_id __read_mostly; extern int tipc_net_id __read_mostly;
extern int sysctl_tipc_rmem[3] __read_mostly; extern int sysctl_tipc_rmem[3] __read_mostly;
extern int sysctl_tipc_named_timeout __read_mostly; extern int sysctl_tipc_named_timeout __read_mostly;
...@@ -106,6 +109,26 @@ struct tipc_net { ...@@ -106,6 +109,26 @@ struct tipc_net {
atomic_t subscription_count; atomic_t subscription_count;
}; };
static inline u16 mod(u16 x)
{
return x & 0xffffu;
}
static inline int less_eq(u16 left, u16 right)
{
return mod(right - left) < 32768u;
}
static inline int more(u16 left, u16 right)
{
return !less_eq(left, right);
}
static inline int less(u16 left, u16 right)
{
return less_eq(left, right) && (mod(right) != mod(left));
}
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
int tipc_register_sysctl(void); int tipc_register_sysctl(void);
void tipc_unregister_sysctl(void); void tipc_unregister_sysctl(void);
......
此差异已折叠。
...@@ -107,30 +107,29 @@ struct tipc_stats { ...@@ -107,30 +107,29 @@ struct tipc_stats {
* @owner: pointer to peer node * @owner: pointer to peer node
* @refcnt: reference counter for permanent references (owner node & timer) * @refcnt: reference counter for permanent references (owner node & timer)
* @flags: execution state flags for link endpoint instance * @flags: execution state flags for link endpoint instance
* @checkpoint: reference point for triggering link continuity checking
* @peer_session: link session # being used by peer end of link * @peer_session: link session # being used by peer end of link
* @peer_bearer_id: bearer id used by link's peer endpoint * @peer_bearer_id: bearer id used by link's peer endpoint
* @bearer_id: local bearer id used by link * @bearer_id: local bearer id used by link
* @tolerance: minimum link continuity loss needed to reset link [in ms] * @tolerance: minimum link continuity loss needed to reset link [in ms]
* @cont_intv: link continuity testing interval * @keepalive_intv: link keepalive timer interval
* @abort_limit: # of unacknowledged continuity probes needed to reset link * @abort_limit: # of unacknowledged continuity probes needed to reset link
* @state: current state of link FSM * @state: current state of link FSM
* @fsm_msg_cnt: # of protocol messages link FSM has sent in current state * @silent_intv_cnt: # of timer intervals without any reception from peer
* @proto_msg: template for control messages generated by link * @proto_msg: template for control messages generated by link
* @pmsg: convenience pointer to "proto_msg" field * @pmsg: convenience pointer to "proto_msg" field
* @priority: current link priority * @priority: current link priority
* @net_plane: current link network plane ('A' through 'H') * @net_plane: current link network plane ('A' through 'H')
* @backlog_limit: backlog queue congestion thresholds (indexed by importance) * @backlog_limit: backlog queue congestion thresholds (indexed by importance)
* @exp_msg_count: # of tunnelled messages expected during link changeover * @exp_msg_count: # of tunnelled messages expected during link changeover
* @reset_checkpoint: seq # of last acknowledged message at time of link reset * @reset_rcv_checkpt: seq # of last acknowledged message at time of link reset
* @mtu: current maximum packet size for this link * @mtu: current maximum packet size for this link
* @advertised_mtu: advertised own mtu when link is being established * @advertised_mtu: advertised own mtu when link is being established
* @transmitq: queue for sent, non-acked messages * @transmitq: queue for sent, non-acked messages
* @backlogq: queue for messages waiting to be sent * @backlogq: queue for messages waiting to be sent
* @next_out_no: next sequence number to use for outbound messages * @snt_nxt: next sequence number to use for outbound messages
* @last_retransmitted: sequence number of most recently retransmitted message * @last_retransmitted: sequence number of most recently retransmitted message
* @stale_count: # of identical retransmit requests made by peer * @stale_count: # of identical retransmit requests made by peer
* @next_in_no: next sequence number to expect for inbound messages * @rcv_nxt: next sequence number to expect for inbound messages
* @deferred_queue: deferred queue saved OOS b'cast message received from node * @deferred_queue: deferred queue saved OOS b'cast message received from node
* @unacked_window: # of inbound messages rx'd without ack'ing back to peer * @unacked_window: # of inbound messages rx'd without ack'ing back to peer
* @inputq: buffer queue for messages to be delivered upwards * @inputq: buffer queue for messages to be delivered upwards
...@@ -151,15 +150,14 @@ struct tipc_link { ...@@ -151,15 +150,14 @@ struct tipc_link {
/* Management and link supervision data */ /* Management and link supervision data */
unsigned int flags; unsigned int flags;
u32 checkpoint;
u32 peer_session; u32 peer_session;
u32 peer_bearer_id; u32 peer_bearer_id;
u32 bearer_id; u32 bearer_id;
u32 tolerance; u32 tolerance;
unsigned long cont_intv; unsigned long keepalive_intv;
u32 abort_limit; u32 abort_limit;
int state; int state;
u32 fsm_msg_cnt; u32 silent_intv_cnt;
struct { struct {
unchar hdr[INT_H_SIZE]; unchar hdr[INT_H_SIZE];
unchar body[TIPC_MAX_IF_NAME]; unchar body[TIPC_MAX_IF_NAME];
...@@ -185,13 +183,13 @@ struct tipc_link { ...@@ -185,13 +183,13 @@ struct tipc_link {
u16 len; u16 len;
u16 limit; u16 limit;
} backlog[5]; } backlog[5];
u32 next_out_no; u16 snd_nxt;
u16 last_retransm;
u32 window; u32 window;
u32 last_retransmitted;
u32 stale_count; u32 stale_count;
/* Reception */ /* Reception */
u32 next_in_no; u16 rcv_nxt;
u32 rcv_unacked; u32 rcv_unacked;
struct sk_buff_head deferdq; struct sk_buff_head deferdq;
struct sk_buff_head inputq; struct sk_buff_head inputq;
...@@ -213,8 +211,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, ...@@ -213,8 +211,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
struct tipc_bearer *b_ptr, struct tipc_bearer *b_ptr,
const struct tipc_media_addr *media_addr); const struct tipc_media_addr *media_addr);
void tipc_link_delete(struct tipc_link *link); void tipc_link_delete(struct tipc_link *link);
void tipc_link_delete_list(struct net *net, unsigned int bearer_id, void tipc_link_delete_list(struct net *net, unsigned int bearer_id);
bool shutting_down);
void tipc_link_failover_send_queue(struct tipc_link *l_ptr); void tipc_link_failover_send_queue(struct tipc_link *l_ptr);
void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, struct tipc_link *dest); void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, struct tipc_link *dest);
void tipc_link_reset_fragments(struct tipc_link *l_ptr); void tipc_link_reset_fragments(struct tipc_link *l_ptr);
...@@ -223,7 +220,6 @@ int tipc_link_is_active(struct tipc_link *l_ptr); ...@@ -223,7 +220,6 @@ int tipc_link_is_active(struct tipc_link *l_ptr);
void tipc_link_purge_queues(struct tipc_link *l_ptr); void tipc_link_purge_queues(struct tipc_link *l_ptr);
void tipc_link_reset_all(struct tipc_node *node); void tipc_link_reset_all(struct tipc_node *node);
void tipc_link_reset(struct tipc_link *l_ptr); void tipc_link_reset(struct tipc_link *l_ptr);
void tipc_link_reset_list(struct net *net, unsigned int bearer_id);
int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest, int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest,
u32 selector); u32 selector);
int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dest, int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dest,
...@@ -247,39 +243,6 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info); ...@@ -247,39 +243,6 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]);
void link_prepare_wakeup(struct tipc_link *l); void link_prepare_wakeup(struct tipc_link *l);
/*
* Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
*/
static inline u32 buf_seqno(struct sk_buff *buf)
{
return msg_seqno(buf_msg(buf));
}
static inline u32 mod(u32 x)
{
return x & 0xffffu;
}
static inline int less_eq(u32 left, u32 right)
{
return mod(right - left) < 32768u;
}
static inline int more(u32 left, u32 right)
{
return !less_eq(left, right);
}
static inline int less(u32 left, u32 right)
{
return less_eq(left, right) && (mod(right) != mod(left));
}
static inline u32 lesser(u32 left, u32 right)
{
return less_eq(left, right) ? left : right;
}
static inline u32 link_own_addr(struct tipc_link *l) static inline u32 link_own_addr(struct tipc_link *l)
{ {
return msg_prevnode(l->pmsg); return msg_prevnode(l->pmsg);
......
...@@ -331,16 +331,15 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, ...@@ -331,16 +331,15 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
/** /**
* tipc_msg_bundle(): Append contents of a buffer to tail of an existing one * tipc_msg_bundle(): Append contents of a buffer to tail of an existing one
* @bskb: the buffer to append to ("bundle") * @skb: the buffer to append to ("bundle")
* @skb: buffer to be appended * @msg: message to be appended
* @mtu: max allowable size for the bundle buffer * @mtu: max allowable size for the bundle buffer
* Consumes buffer if successful * Consumes buffer if successful
* Returns true if bundling could be performed, otherwise false * Returns true if bundling could be performed, otherwise false
*/ */
bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu) bool tipc_msg_bundle(struct sk_buff *skb, struct tipc_msg *msg, u32 mtu)
{ {
struct tipc_msg *bmsg; struct tipc_msg *bmsg;
struct tipc_msg *msg = buf_msg(skb);
unsigned int bsz; unsigned int bsz;
unsigned int msz = msg_size(msg); unsigned int msz = msg_size(msg);
u32 start, pad; u32 start, pad;
...@@ -348,9 +347,9 @@ bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu) ...@@ -348,9 +347,9 @@ bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu)
if (likely(msg_user(msg) == MSG_FRAGMENTER)) if (likely(msg_user(msg) == MSG_FRAGMENTER))
return false; return false;
if (!bskb) if (!skb)
return false; return false;
bmsg = buf_msg(bskb); bmsg = buf_msg(skb);
bsz = msg_size(bmsg); bsz = msg_size(bmsg);
start = align(bsz); start = align(bsz);
pad = start - bsz; pad = start - bsz;
...@@ -359,18 +358,20 @@ bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu) ...@@ -359,18 +358,20 @@ bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu)
return false; return false;
if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) if (unlikely(msg_user(msg) == BCAST_PROTOCOL))
return false; return false;
if (likely(msg_user(bmsg) != MSG_BUNDLER)) if (unlikely(msg_user(bmsg) != MSG_BUNDLER))
return false; return false;
if (unlikely(skb_tailroom(bskb) < (pad + msz))) if (unlikely(skb_tailroom(skb) < (pad + msz)))
return false; return false;
if (unlikely(max < (start + msz))) if (unlikely(max < (start + msz)))
return false; return false;
if ((msg_importance(msg) < TIPC_SYSTEM_IMPORTANCE) &&
(msg_importance(bmsg) == TIPC_SYSTEM_IMPORTANCE))
return false;
skb_put(bskb, pad + msz); skb_put(skb, pad + msz);
skb_copy_to_linear_data_offset(bskb, start, skb->data, msz); skb_copy_to_linear_data_offset(skb, start, msg, msz);
msg_set_size(bmsg, start + msz); msg_set_size(bmsg, start + msz);
msg_set_msgcnt(bmsg, msg_msgcnt(bmsg) + 1); msg_set_msgcnt(bmsg, msg_msgcnt(bmsg) + 1);
kfree_skb(skb);
return true; return true;
} }
...@@ -416,18 +417,18 @@ bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos) ...@@ -416,18 +417,18 @@ bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos)
/** /**
* tipc_msg_make_bundle(): Create bundle buf and append message to its tail * tipc_msg_make_bundle(): Create bundle buf and append message to its tail
* @list: the buffer chain * @list: the buffer chain, where head is the buffer to replace/append
* @skb: buffer to be appended and replaced * @skb: buffer to be created, appended to and returned in case of success
* @msg: message to be appended
* @mtu: max allowable size for the bundle buffer, inclusive header * @mtu: max allowable size for the bundle buffer, inclusive header
* @dnode: destination node for message. (Not always present in header) * @dnode: destination node for message. (Not always present in header)
* Replaces buffer if successful
* Returns true if success, otherwise false * Returns true if success, otherwise false
*/ */
bool tipc_msg_make_bundle(struct sk_buff **skb, u32 mtu, u32 dnode) bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
u32 mtu, u32 dnode)
{ {
struct sk_buff *bskb; struct sk_buff *_skb;
struct tipc_msg *bmsg; struct tipc_msg *bmsg;
struct tipc_msg *msg = buf_msg(*skb);
u32 msz = msg_size(msg); u32 msz = msg_size(msg);
u32 max = mtu - INT_H_SIZE; u32 max = mtu - INT_H_SIZE;
...@@ -440,19 +441,23 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, u32 mtu, u32 dnode) ...@@ -440,19 +441,23 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, u32 mtu, u32 dnode)
if (msz > (max / 2)) if (msz > (max / 2))
return false; return false;
bskb = tipc_buf_acquire(max); _skb = tipc_buf_acquire(max);
if (!bskb) if (!_skb)
return false; return false;
skb_trim(bskb, INT_H_SIZE); skb_trim(_skb, INT_H_SIZE);
bmsg = buf_msg(bskb); bmsg = buf_msg(_skb);
tipc_msg_init(msg_prevnode(msg), bmsg, MSG_BUNDLER, 0, tipc_msg_init(msg_prevnode(msg), bmsg, MSG_BUNDLER, 0,
INT_H_SIZE, dnode); INT_H_SIZE, dnode);
if (msg_isdata(msg))
msg_set_importance(bmsg, TIPC_CRITICAL_IMPORTANCE);
else
msg_set_importance(bmsg, TIPC_SYSTEM_IMPORTANCE);
msg_set_seqno(bmsg, msg_seqno(msg)); msg_set_seqno(bmsg, msg_seqno(msg));
msg_set_ack(bmsg, msg_ack(msg)); msg_set_ack(bmsg, msg_ack(msg));
msg_set_bcast_ack(bmsg, msg_bcast_ack(msg)); msg_set_bcast_ack(bmsg, msg_bcast_ack(msg));
tipc_msg_bundle(bskb, *skb, mtu); tipc_msg_bundle(_skb, msg, mtu);
*skb = bskb; *skb = _skb;
return true; return true;
} }
......
...@@ -313,12 +313,12 @@ static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n) ...@@ -313,12 +313,12 @@ static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n)
msg_set_bits(m, 1, 19, 0x3, n); msg_set_bits(m, 1, 19, 0x3, n);
} }
static inline u32 msg_bcast_ack(struct tipc_msg *m) static inline u16 msg_bcast_ack(struct tipc_msg *m)
{ {
return msg_bits(m, 1, 0, 0xffff); return msg_bits(m, 1, 0, 0xffff);
} }
static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n) static inline void msg_set_bcast_ack(struct tipc_msg *m, u16 n)
{ {
msg_set_bits(m, 1, 0, 0xffff, n); msg_set_bits(m, 1, 0, 0xffff, n);
} }
...@@ -327,22 +327,22 @@ static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n) ...@@ -327,22 +327,22 @@ static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n)
/* /*
* Word 2 * Word 2
*/ */
static inline u32 msg_ack(struct tipc_msg *m) static inline u16 msg_ack(struct tipc_msg *m)
{ {
return msg_bits(m, 2, 16, 0xffff); return msg_bits(m, 2, 16, 0xffff);
} }
static inline void msg_set_ack(struct tipc_msg *m, u32 n) static inline void msg_set_ack(struct tipc_msg *m, u16 n)
{ {
msg_set_bits(m, 2, 16, 0xffff, n); msg_set_bits(m, 2, 16, 0xffff, n);
} }
static inline u32 msg_seqno(struct tipc_msg *m) static inline u16 msg_seqno(struct tipc_msg *m)
{ {
return msg_bits(m, 2, 0, 0xffff); return msg_bits(m, 2, 0, 0xffff);
} }
static inline void msg_set_seqno(struct tipc_msg *m, u32 n) static inline void msg_set_seqno(struct tipc_msg *m, u16 n)
{ {
msg_set_bits(m, 2, 0, 0xffff, n); msg_set_bits(m, 2, 0, 0xffff, n);
} }
...@@ -352,18 +352,22 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n) ...@@ -352,18 +352,22 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n)
*/ */
static inline u32 msg_importance(struct tipc_msg *m) static inline u32 msg_importance(struct tipc_msg *m)
{ {
if (unlikely(msg_user(m) == MSG_FRAGMENTER)) int usr = msg_user(m);
if (likely((usr <= TIPC_CRITICAL_IMPORTANCE) && !msg_errcode(m)))
return usr;
if ((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER))
return msg_bits(m, 5, 13, 0x7); return msg_bits(m, 5, 13, 0x7);
if (likely(msg_isdata(m) && !msg_errcode(m)))
return msg_user(m);
return TIPC_SYSTEM_IMPORTANCE; return TIPC_SYSTEM_IMPORTANCE;
} }
static inline void msg_set_importance(struct tipc_msg *m, u32 i) static inline void msg_set_importance(struct tipc_msg *m, u32 i)
{ {
if (unlikely(msg_user(m) == MSG_FRAGMENTER)) int usr = msg_user(m);
if (likely((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER)))
msg_set_bits(m, 5, 13, 0x7, i); msg_set_bits(m, 5, 13, 0x7, i);
else if (likely(i < TIPC_SYSTEM_IMPORTANCE)) else if (i < TIPC_SYSTEM_IMPORTANCE)
msg_set_user(m, i); msg_set_user(m, i);
else else
pr_warn("Trying to set illegal importance in message\n"); pr_warn("Trying to set illegal importance in message\n");
...@@ -772,9 +776,9 @@ struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, ...@@ -772,9 +776,9 @@ struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
uint data_sz, u32 dnode, u32 onode, uint data_sz, u32 dnode, u32 onode,
u32 dport, u32 oport, int errcode); u32 dport, u32 oport, int errcode);
int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf); int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf);
bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu); bool tipc_msg_bundle(struct sk_buff *skb, struct tipc_msg *msg, u32 mtu);
bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
bool tipc_msg_make_bundle(struct sk_buff **skb, u32 mtu, u32 dnode); u32 mtu, u32 dnode);
bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos); bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos);
int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
int offset, int dsz, int mtu, struct sk_buff_head *list); int offset, int dsz, int mtu, struct sk_buff_head *list);
...@@ -782,6 +786,11 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, u32 *dnode, ...@@ -782,6 +786,11 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, u32 *dnode,
int *err); int *err);
struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list); struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list);
static inline u16 buf_seqno(struct sk_buff *skb)
{
return msg_seqno(buf_msg(skb));
}
/* tipc_skb_peek(): peek and reserve first buffer in list /* tipc_skb_peek(): peek and reserve first buffer in list
* @list: list to be peeked in * @list: list to be peeked in
* Returns pointer to first buffer in list, if any * Returns pointer to first buffer in list, if any
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "subscr.h" #include "subscr.h"
#include "socket.h" #include "socket.h"
#include "node.h" #include "node.h"
#include "bcast.h"
static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = { static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
[TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC }, [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
......
/* /*
* net/tipc/node.c: TIPC node management routines * net/tipc/node.c: TIPC node management routines
* *
* Copyright (c) 2000-2006, 2012-2014, Ericsson AB * Copyright (c) 2000-2006, 2012-2015, Ericsson AB
* Copyright (c) 2005-2006, 2010-2014, Wind River Systems * Copyright (c) 2005-2006, 2010-2014, Wind River Systems
* All rights reserved. * All rights reserved.
* *
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "node.h" #include "node.h"
#include "name_distr.h" #include "name_distr.h"
#include "socket.h" #include "socket.h"
#include "bcast.h"
static void node_lost_contact(struct tipc_node *n_ptr); static void node_lost_contact(struct tipc_node *n_ptr);
static void node_established_contact(struct tipc_node *n_ptr); static void node_established_contact(struct tipc_node *n_ptr);
......
...@@ -45,8 +45,6 @@ ...@@ -45,8 +45,6 @@
/* Out-of-range value for node signature */ /* Out-of-range value for node signature */
#define INVALID_NODE_SIG 0x10000 #define INVALID_NODE_SIG 0x10000
#define NODE_HTABLE_SIZE 512
/* Flags used to take different actions according to flag type /* Flags used to take different actions according to flag type
* TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
* TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "link.h" #include "link.h"
#include "name_distr.h" #include "name_distr.h"
#include "socket.h" #include "socket.h"
#include "bcast.h"
#define SS_LISTENING -1 /* socket is listening */ #define SS_LISTENING -1 /* socket is listening */
#define SS_READY -2 /* socket is connectionless */ #define SS_READY -2 /* socket is connectionless */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册