diff --git a/kmod_utils.c b/kmod_utils.c index 2884e9a..68b244d 100644 --- a/kmod_utils.c +++ b/kmod_utils.c @@ -65,16 +65,8 @@ static int send_raw_ipv4(const uint8_t *pkt, uint32_t pktlen) { memset(&msg, 0, sizeof(msg)); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) iov.iov_base = (__u8 *)pkt; iov.iov_len = pktlen; - iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, 1); -#else - iov.iov_base = (__u8 *)pkt; - iov.iov_len = pktlen; - // msg.msg_iov = (struct iovec *)&iov; - // msg.msg_iovlen = iov.iov_len; -#endif msg.msg_flags = 0; msg.msg_name = &daddr; @@ -133,16 +125,8 @@ int send_raw_ipv6(const uint8_t *pkt, uint32_t pktlen) { struct msghdr msg; memset(&msg, 0, sizeof(msg)); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) iov.iov_base = (__u8 *)pkt; iov.iov_len = pktlen; - iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, 1); -#else - iov.iov_base = (__u8 *)pkt; - iov.iov_len = pktlen; - // msg.msg_iov = (struct iovec *)&iov; - // msg.msg_iovlen = iov.iov_len; -#endif msg.msg_flags = 0; msg.msg_name = &daddr; diff --git a/mangle.c b/mangle.c index c0918e5..3265f7d 100644 --- a/mangle.c +++ b/mangle.c @@ -1037,7 +1037,12 @@ int fail_packet(uint8_t *payload, uint32_t *plen, uint32_t avail_buflen) { return -1; } uint8_t *ndata = data + delta; - memcpy(ndata, data, dlen); + uint8_t *ndptr = ndata + dlen; + uint8_t *dptr = data + dlen; + for (size_t i = dlen + 1; i > 0; i--) { + *ndptr = *dptr; + --ndptr, --dptr; + } data = ndata; tcph_len = tcph_len + delta; tcph->doff = tcph_len >> 2; diff --git a/types.h b/types.h index 81b3b8e..777601d 100644 --- a/types.h +++ b/types.h @@ -93,7 +93,7 @@ typedef __u64 uint64_t; */ #ifdef KERNEL_SPACE #include -#define NETBUF_ALLOC(buf, buf_len) __u8* buf = kmalloc(buf_len, GFP_ATOMIC); +#define NETBUF_ALLOC(buf, buf_len) __u8* buf = kmalloc(buf_len, GFP_KERNEL); #define NETBUF_CHECK(buf) ((buf) != NULL) #define NETBUF_FREE(buf) kfree(buf); #elif defined(ALLOC_MALLOC)