Skip to content

Commit

Permalink
rxe: Fix send function return value
Browse files Browse the repository at this point in the history
Fix send function return value and make sure that SKB is not freed
until it xmited.

Issue: None

Change-Id: I84406c5e332fadb538eaf6ae84a666380affe1cf
Signed-off-by: Kamal Heib <[email protected]>
  • Loading branch information
Kamal Heib committed Apr 28, 2015
1 parent c3790b2 commit 5f2eb10
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions drivers/infiniband/hw/rxe/rxe_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,42 +246,53 @@ static void rxe_release_udp_tunnel(struct socket *sk)

static int send(struct rxe_dev *rxe, struct sk_buff *skb)
{
int sent_bytes = 0;
struct sk_buff *nskb;
bool csum_nocheck = true;
struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
struct rxe_av *av = pkt->av;

nskb = skb_clone(skb, GFP_ATOMIC);
if (!nskb)
return -ENOMEM;

if (av->network_type == RDMA_NETWORK_IPV4) {
__be16 df = 0;
bool xnet = false;
struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr;
struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr;
struct rtable *rt = rxe_find_route4(saddr, daddr);

return udp_tunnel_xmit_skb(rt, skb, saddr->s_addr,
daddr->s_addr,
av->attr.grh.traffic_class,
av->attr.grh.hop_limit,
df, htons(0xc000),
htons(ROCE_V2_UDP_DPORT),
xnet,
csum_nocheck);
sent_bytes = udp_tunnel_xmit_skb(rt, nskb, saddr->s_addr,
daddr->s_addr,
av->attr.grh.traffic_class,
av->attr.grh.hop_limit,
df, htons(0xc000),
htons(ROCE_V2_UDP_DPORT),
xnet,
csum_nocheck);

} else if (av->network_type == RDMA_NETWORK_IPV6) {
struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr;
struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr;
struct dst_entry *dst = rxe_find_route6(rxe->ndev,
saddr, daddr);

return udp_tunnel6_xmit_skb(dst, skb, rxe->ndev,
saddr, daddr,
av->attr.grh.traffic_class,
av->attr.grh.hop_limit,
htons(0xc000),
htons(ROCE_V2_UDP_DPORT),
csum_nocheck);
sent_bytes = udp_tunnel6_xmit_skb(dst, nskb, rxe->ndev,
saddr, daddr,
av->attr.grh.traffic_class,
av->attr.grh.hop_limit,
htons(0xc000),
htons(ROCE_V2_UDP_DPORT),
csum_nocheck);
}

if (sent_bytes > 0) {
kfree_skb(skb);
return 0;
}

return -1;
return sent_bytes < 0 ? sent_bytes : -EAGAIN;
}

static int loopback(struct sk_buff *skb)
Expand Down

0 comments on commit 5f2eb10

Please sign in to comment.