From: <eri...@er...> - 2012-03-30 14:54:17
|
From: Erik Hugne <eri...@er...> This makes it possible to create mapping of priority to Ethernet 802.1p (priority bits) using lartc or vconfig egress_map for TIPC user data traffic. In addition to copying socket priority to the SKB in tipc_msg_build, priority is also assigned to the allocated SKB's when: -A new bundling buffer is allocated on the link -Message fragmentation buffers are allocated -Link changeover occurs and the packets buffered on the defunct link are duplicated to the new active link. -Port level control messages are allocated This change does not impact link level control messsages. Signed-off-by: Erik Hugne <eri...@er...> --- net/tipc/link.c | 12 ++++++++++++ net/tipc/msg.c | 7 +++++++ net/tipc/port.c | 11 +++++++++-- net/tipc/port.h | 10 ++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index 8ad8f4f..72b055b 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -929,6 +929,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) INT_H_SIZE, l_ptr->addr); skb_copy_to_linear_data(bundler, &bundler_hdr, INT_H_SIZE); + bundler->priority = buf->priority; skb_trim(bundler, INT_H_SIZE); link_bundle_buf(l_ptr, bundler, buf); buf = bundler; @@ -1204,6 +1205,7 @@ static int link_send_sections_long(struct tipc_port *sender, const unchar *sect_crs; int curr_sect; u32 fragm_no; + u32 priority; again: fragm_no = 1; @@ -1231,6 +1233,7 @@ again: if (!buf) return -ENOMEM; buf->next = NULL; + priority = tipc_sk_priority(sender); skb_copy_to_linear_data(buf, &fragm_hdr, INT_H_SIZE); hsz = msg_hdr_sz(hdr); skb_copy_to_linear_data_offset(buf, INT_H_SIZE, hdr, hsz); @@ -1243,6 +1246,7 @@ again: do { /* For all sections */ u32 sz; + buf->priority = priority; if (!sect_rest) { sect_rest = (u32)msg_sect[++curr_sect].iov_len; sect_crs = (const unchar *)msg_sect[curr_sect].iov_base; @@ -2210,6 +2214,7 @@ static void tipc_link_tunnel(struct link *l_ptr, { struct link *tunnel; struct sk_buff *buf; + struct sk_buff *obuf; u32 length = msg_size(msg); tunnel = l_ptr->owner->active_links[selector & 1]; @@ -2220,11 +2225,16 @@ static void tipc_link_tunnel(struct link *l_ptr, } msg_set_size(tunnel_hdr, length + INT_H_SIZE); buf = tipc_buf_acquire(length + INT_H_SIZE); + if (!buf) { warn("Link changeover error, " "unable to send tunnel msg\n"); return; } + /*Copy the priority of the original skb to the tunneled one*/ + obuf = container_of((void *)msg, struct sk_buff, data); + if (obuf) + buf->priority = obuf->priority; skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE); skb_copy_to_linear_data_offset(buf, INT_H_SIZE, msg, length); tipc_link_send_buf(tunnel, buf); @@ -2326,6 +2336,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) "unable to send duplicate msg\n"); return; } + outbuf->priority = iter->priority; skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE); skb_copy_to_linear_data_offset(outbuf, INT_H_SIZE, iter->data, length); @@ -2512,6 +2523,7 @@ static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) } return -ENOMEM; } + fragm->priority = buf->priority; msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); fragm_no++; msg_set_fragm_no(&fragm_hdr, fragm_no); diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 3b5d43d..4b0f913 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -33,8 +33,10 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <net/sock.h> #include "core.h" +#include "port.h" #include "msg.h" u32 tipc_msg_tot_importance(struct tipc_msg *m) @@ -79,6 +81,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, { int dsz, sz, hsz, pos, res; u32 cnt; + struct tipc_port *oport; dsz = total_len; pos = hsz = msg_hdr_sz(hdr); @@ -92,6 +95,10 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, *buf = tipc_buf_acquire(sz); if (!(*buf)) return -ENOMEM; + + oport = container_of((void *)hdr, struct tipc_port, phdr); + if (oport) + (*buf)->priority = tipc_sk_priority(oport); skb_copy_to_linear_data(*buf, hdr, hsz); for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { if (likely(usrmem)) diff --git a/net/tipc/port.c b/net/tipc/port.c index d634aab..270eca6 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -368,6 +368,7 @@ static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr, buf = tipc_buf_acquire(INT_H_SIZE); if (buf) { + buf->priority = tipc_sk_priority(p_ptr); msg = buf_msg(buf); tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE, port_peernode(p_ptr)); @@ -383,6 +384,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) struct tipc_msg *msg = buf_msg(buf); struct sk_buff *rbuf; struct tipc_msg *rmsg; + struct tipc_port *p_ptr; int hdr_sz; u32 data_sz = msg_data_sz(msg); u32 src_node; @@ -425,16 +427,20 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) /* send self-abort message when rejecting on a connected port */ if (msg_connected(msg)) { - struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg)); + p_ptr = tipc_port_lock(msg_destport(msg)); if (p_ptr) { struct sk_buff *abuf = NULL; - + rbuf->priority = tipc_sk_priority(p_ptr); if (p_ptr->connected) abuf = port_build_self_abort_msg(p_ptr, err); tipc_port_unlock(p_ptr); tipc_net_route_msg(abuf); } + } else { + p_ptr = tipc_ref_deref(msg_destport(msg)); + if (p_ptr) + rbuf->priority = tipc_sk_priority(p_ptr); } /* send returned message & dispose of rejected message */ @@ -528,6 +534,7 @@ static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 er buf = tipc_buf_acquire(BASIC_H_SIZE); if (buf) { + buf->priority = tipc_sk_priority(p_ptr); msg = buf_msg(buf); memcpy(msg, &p_ptr->phdr, BASIC_H_SIZE); msg_set_hdr_sz(msg, BASIC_H_SIZE); diff --git a/net/tipc/port.h b/net/tipc/port.h index 410f5be..7c61495 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h @@ -37,6 +37,8 @@ #ifndef _TIPC_PORT_H #define _TIPC_PORT_H +#include <net/sock.h> + #include "ref.h" #include "net.h" #include "msg.h" @@ -264,4 +266,12 @@ static inline int tipc_port_congested(struct tipc_port *p_ptr) return (p_ptr->sent - p_ptr->acked) >= TIPC_CONN_MSG_WINDOW; } +static inline int tipc_sk_priority(const struct tipc_port *p_ptr) +{ + struct sock *sk = (struct sock *)p_ptr->usr_handle; + if (sk) + return sk->sk_priority; + return 0; +} + #endif -- 1.7.5.4 |