mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
netpoll: factor out UDP header setup into push_udp() helper
Move UDP header construction from netpoll_send_udp() into a new static helper function push_udp(). This completes the protocol layer refactoring by: 1. Creating a dedicated helper for UDP header assembly 2. Removing UDP-specific logic from the main send function 3. Establishing a consistent pattern with existing IPv4/IPv6 helpers: - push_udp() - push_ipv4() - push_ipv6() The change improves code organization and maintains the encapsulation pattern established in previous refactorings. Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250702-netpoll_untagle_ip-v2-5-13cf3db24e2b@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
8c27639dbe
commit
cacfb1f4e9
|
|
@ -473,11 +473,28 @@ static void push_ipv4(struct netpoll *np, struct sk_buff *skb, int len)
|
||||||
eth->h_proto = htons(ETH_P_IP);
|
eth->h_proto = htons(ETH_P_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void push_udp(struct netpoll *np, struct sk_buff *skb, int len)
|
||||||
|
{
|
||||||
|
struct udphdr *udph;
|
||||||
|
int udp_len;
|
||||||
|
|
||||||
|
udp_len = len + sizeof(struct udphdr);
|
||||||
|
|
||||||
|
skb_push(skb, sizeof(struct udphdr));
|
||||||
|
skb_reset_transport_header(skb);
|
||||||
|
|
||||||
|
udph = udp_hdr(skb);
|
||||||
|
udph->source = htons(np->local_port);
|
||||||
|
udph->dest = htons(np->remote_port);
|
||||||
|
udph->len = htons(udp_len);
|
||||||
|
|
||||||
|
netpoll_udp_checksum(np, skb, len);
|
||||||
|
}
|
||||||
|
|
||||||
int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
|
int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
|
||||||
{
|
{
|
||||||
int total_len, ip_len, udp_len;
|
int total_len, ip_len, udp_len;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct udphdr *udph;
|
|
||||||
struct ethhdr *eth;
|
struct ethhdr *eth;
|
||||||
|
|
||||||
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
|
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
|
||||||
|
|
@ -499,14 +516,7 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
|
||||||
skb_copy_to_linear_data(skb, msg, len);
|
skb_copy_to_linear_data(skb, msg, len);
|
||||||
skb_put(skb, len);
|
skb_put(skb, len);
|
||||||
|
|
||||||
skb_push(skb, sizeof(struct udphdr));
|
push_udp(np, skb, len);
|
||||||
skb_reset_transport_header(skb);
|
|
||||||
udph = udp_hdr(skb);
|
|
||||||
udph->source = htons(np->local_port);
|
|
||||||
udph->dest = htons(np->remote_port);
|
|
||||||
udph->len = htons(udp_len);
|
|
||||||
|
|
||||||
netpoll_udp_checksum(np, skb, len);
|
|
||||||
if (np->ipv6)
|
if (np->ipv6)
|
||||||
push_ipv6(np, skb, len);
|
push_ipv6(np, skb, len);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user