Skip to content

Commit ce984da

Browse files
Richard Alpedavem330
authored andcommitted
tipc: split UDP send function
Split the UDP send function into two. One callback that prepares the skb and one transmit function that sends the skb. This will come in handy in later patches, when we introduce UDP replicast. Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ba5aa84 commit ce984da

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

net/tipc/udp_media.c

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,13 @@ static int tipc_udp_addr2msg(char *msg, struct tipc_media_addr *a)
140140
}
141141

142142
/* tipc_send_msg - enqueue a send request */
143-
static int tipc_udp_send_msg(struct net *net, struct sk_buff *skb,
144-
struct tipc_bearer *b,
145-
struct tipc_media_addr *dest)
143+
static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
144+
struct udp_bearer *ub, struct udp_media_addr *src,
145+
struct udp_media_addr *dst)
146146
{
147147
int ttl, err = 0;
148-
struct udp_bearer *ub;
149-
struct udp_media_addr *dst = (struct udp_media_addr *)&dest->value;
150-
struct udp_media_addr *src = (struct udp_media_addr *)&b->addr.value;
151148
struct rtable *rt;
152149

153-
if (skb_headroom(skb) < UDP_MIN_HEADROOM) {
154-
err = pskb_expand_head(skb, UDP_MIN_HEADROOM, 0, GFP_ATOMIC);
155-
if (err)
156-
goto tx_error;
157-
}
158-
159-
skb_set_inner_protocol(skb, htons(ETH_P_TIPC));
160-
ub = rcu_dereference_rtnl(b->media_ptr);
161-
if (!ub) {
162-
err = -ENODEV;
163-
goto tx_error;
164-
}
165150
if (dst->proto == htons(ETH_P_IP)) {
166151
struct flowi4 fl = {
167152
.daddr = dst->ipv4.s_addr,
@@ -207,6 +192,35 @@ static int tipc_udp_send_msg(struct net *net, struct sk_buff *skb,
207192
return err;
208193
}
209194

195+
static int tipc_udp_send_msg(struct net *net, struct sk_buff *skb,
196+
struct tipc_bearer *b,
197+
struct tipc_media_addr *addr)
198+
{
199+
struct udp_media_addr *src = (struct udp_media_addr *)&b->addr.value;
200+
struct udp_media_addr *dst = (struct udp_media_addr *)&addr->value;
201+
struct udp_bearer *ub;
202+
int err = 0;
203+
204+
if (skb_headroom(skb) < UDP_MIN_HEADROOM) {
205+
err = pskb_expand_head(skb, UDP_MIN_HEADROOM, 0, GFP_ATOMIC);
206+
if (err)
207+
goto tx_error;
208+
}
209+
210+
skb_set_inner_protocol(skb, htons(ETH_P_TIPC));
211+
ub = rcu_dereference_rtnl(b->media_ptr);
212+
if (!ub) {
213+
err = -ENODEV;
214+
goto tx_error;
215+
}
216+
217+
return tipc_udp_xmit(net, skb, ub, src, dst);
218+
219+
tx_error:
220+
kfree_skb(skb);
221+
return err;
222+
}
223+
210224
/* tipc_udp_recv - read data from bearer socket */
211225
static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb)
212226
{

0 commit comments

Comments
 (0)