Remove support for TCP packets from tap_ip_send()
tap_ip_send() is never used for TCP packets, we're unlikely to use it for that in future, and the handling of TCP packets makes other cleanups unnecessarily awkward. Remove it. This is the only user of csum_tcp4(), so we can remove that as well. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
a2eb2d310a
commit
f72b63e92f
3 changed files with 2 additions and 44 deletions
34
checksum.c
34
checksum.c
|
@ -211,40 +211,6 @@ void csum_icmp6(struct icmp6hdr *icmp6hr,
|
|||
icmp6hr->icmp6_cksum = csum_unaligned(payload, len, psum);
|
||||
}
|
||||
|
||||
/**
|
||||
* csum_tcp4() - Calculate TCP checksum for IPv4 and set in place
|
||||
* @iph: Packet buffer, IP header
|
||||
*/
|
||||
void csum_tcp4(struct iphdr *iph)
|
||||
{
|
||||
uint16_t tlen = ntohs(iph->tot_len) - iph->ihl * 4, *p;
|
||||
struct tcphdr *th;
|
||||
uint32_t sum = 0;
|
||||
|
||||
th = (struct tcphdr *)((char *)iph + (intptr_t)(iph->ihl * 4));
|
||||
p = (uint16_t *)th;
|
||||
|
||||
sum += (iph->saddr >> 16) & 0xffff;
|
||||
sum += iph->saddr & 0xffff;
|
||||
sum += (iph->daddr >> 16) & 0xffff;
|
||||
sum += iph->daddr & 0xffff;
|
||||
|
||||
sum += htons(IPPROTO_TCP);
|
||||
sum += htons(tlen);
|
||||
|
||||
th->check = 0;
|
||||
while (tlen > 1) {
|
||||
sum += *p++;
|
||||
tlen -= 2;
|
||||
}
|
||||
|
||||
if (tlen > 0) {
|
||||
sum += *p & htons(0xff00);
|
||||
}
|
||||
|
||||
th->check = (uint16_t)~csum_fold(sum);
|
||||
}
|
||||
|
||||
#ifdef __AVX2__
|
||||
#include <immintrin.h>
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ void csum_udp6(struct udphdr *udp6hr,
|
|||
void csum_icmp6(struct icmp6hdr *icmp6hr,
|
||||
const struct in6_addr *saddr, const struct in6_addr *daddr,
|
||||
const void *payload, size_t len);
|
||||
void csum_tcp4(struct iphdr *iph);
|
||||
uint16_t csum(const void *buf, size_t len, uint32_t init);
|
||||
|
||||
#endif /* CHECKSUM_H */
|
||||
|
|
11
tap.c
11
tap.c
|
@ -165,9 +165,7 @@ void tap_ip_send(const struct ctx *c, const struct in6_addr *src, uint8_t proto,
|
|||
|
||||
memcpy(data, in, len);
|
||||
|
||||
if (iph->protocol == IPPROTO_TCP) {
|
||||
csum_tcp4(iph);
|
||||
} else if (iph->protocol == IPPROTO_UDP) {
|
||||
if (iph->protocol == IPPROTO_UDP) {
|
||||
struct udphdr *uh = (struct udphdr *)(iph + 1);
|
||||
|
||||
csum_udp4(uh, iph->saddr, iph->daddr, uh + 1, len - sizeof(*uh));
|
||||
|
@ -196,13 +194,8 @@ void tap_ip_send(const struct ctx *c, const struct in6_addr *src, uint8_t proto,
|
|||
ip6h->hop_limit = proto;
|
||||
ip6h->version = 0;
|
||||
ip6h->nexthdr = 0;
|
||||
if (proto == IPPROTO_TCP) {
|
||||
struct tcphdr *th = (struct tcphdr *)(ip6h + 1);
|
||||
|
||||
th->check = 0;
|
||||
th->check = csum_unaligned(ip6h, len + sizeof(*ip6h),
|
||||
0);
|
||||
} else if (proto == IPPROTO_UDP) {
|
||||
if (proto == IPPROTO_UDP) {
|
||||
struct udphdr *uh = (struct udphdr *)(ip6h + 1);
|
||||
|
||||
csum_udp6(uh, &ip6h->saddr, &ip6h->daddr,
|
||||
|
|
Loading…
Reference in a new issue