Skip to content

Commit a61b19f

Browse files
mkutsevolkuba-moo
authored andcommitted
netpoll: Make netpoll_send_udp return status instead of void
netpoll_send_udp can return if send was successful. It will allow client code to be aware of the send status. Possible return values are the result of __netpoll_send_skb (cast to int) and -ENOMEM. This doesn't cover the case when TX was not successful instantaneously and was scheduled for later, __netpoll__send_skb returns success in that case. Signed-off-by: Maksym Kutsevol <[email protected]> Link: https://patch.msgid.link/20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-1-70e82239f922@kutsevol.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a9ab02e commit a61b19f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/linux/netpoll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline void netpoll_poll_disable(struct net_device *dev) { return; }
5757
static inline void netpoll_poll_enable(struct net_device *dev) { return; }
5858
#endif
5959

60-
void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
60+
int netpoll_send_udp(struct netpoll *np, const char *msg, int len);
6161
void netpoll_print_options(struct netpoll *np);
6262
int netpoll_parse_options(struct netpoll *np, char *opt);
6363
int __netpoll_setup(struct netpoll *np, struct net_device *ndev);

net/core/netpoll.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
390390
}
391391
EXPORT_SYMBOL(netpoll_send_skb);
392392

393-
void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
393+
int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
394394
{
395395
int total_len, ip_len, udp_len;
396396
struct sk_buff *skb;
@@ -414,7 +414,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
414414
skb = find_skb(np, total_len + np->dev->needed_tailroom,
415415
total_len - len);
416416
if (!skb)
417-
return;
417+
return -ENOMEM;
418418

419419
skb_copy_to_linear_data(skb, msg, len);
420420
skb_put(skb, len);
@@ -490,7 +490,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
490490

491491
skb->dev = np->dev;
492492

493-
netpoll_send_skb(np, skb);
493+
return (int)netpoll_send_skb(np, skb);
494494
}
495495
EXPORT_SYMBOL(netpoll_send_udp);
496496

0 commit comments

Comments
 (0)