search for: iphdr

Displaying 20 results from an estimated 62 matches for "iphdr".

Did you mean: phdr
2018 Sep 25
2
bpf compilation using clang
...nhoff + offsetof(struct vlan_hdr, h_vlan_encapsulated_proto)); nhoff += sizeof(struct vlan_hdr); } if (likely(proto == ETH_P_IP)) { struct ipv4_l3_l4_tuple v4_tuple = { .src_addr = IPv4(load_byte(skb, nhoff + offsetof(struct iphdr, saddr)), load_byte(skb, nhoff + offsetof(struct iphdr, saddr) + 1), load_byte(skb, nhoff + offsetof(struct iphdr, saddr) + 2), load_byte(skb, nhoff + offsetof(struct iphdr, sa...
2018 Sep 13
4
bpf compilation using clang
Hi all, I am trying to insert instructions into the bpf using the bpf syscall, the instructions were generated using the following command line: clang -I ~/Builds/bpf_rss/iproute2/include -Wall -target bpf -O2 -emit-llvm -c upstream/qemu/hw/net/rss_tap_bpf_program.c -o - | llc -march=bpf -filetype=obj -o tap_bpf_program.o and then were translated to bpf instructions using the BPFCparser tool
2008 Sep 12
4
Custom build kernel patch fails big time.
...> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> +#include <net/inet_ecn.h> #include <net/ip.h> #include <net/xfrm.h> @@ -23,6 +24,15 @@ EXPORT_SYMBOL(xfrm4_rcv); +static inline void ipip_ecn_decapsulate(struct sk_buff *skb) +{ + struct iphdr *outer_iph = skb->nh.iph; + struct iphdr *inner_iph = skb->h.ipiph; + + if (INET_ECN_is_ce(outer_iph->tos)) + IP_ECN_set_ce(inner_iph); +} + static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq) { switch (nexthdr) { @@ -103,11 +113,11 @@...
2002 Mar 20
1
RMySQL integer range bug (PR#1400)
...(NULL) (131.220.6.43) There is a bug when retrieving values out of MySQL (3.23.36) which are of type UNSIGNED INTEGER(10). The values can vary between 0 and 2^32 but R only accepts those below 2^31-1. Anything above goes as 2^31-1. thats what one gets: print(quickSQL(con,"select ip_dst from iphdr where ip_dst>=2212233216 limit 5")) ip_dst 1 2147483647 2 2147483647 3 2147483647 4 2147483647 5 2147483647 and thats what the numbers really are (conversion to character type first): print(quickSQL(con,"select concat(ip_dst) from iphdr where ip_dst>=2212233216 limit 5")...
2013 Nov 28
4
[PATCH net] xen-netback: fix fragment detection in checksum setup
...-) diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 919b650..eea7ff2 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -1165,15 +1165,27 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, struct iphdr *iph = (void *)skb->data; unsigned int header_size; unsigned int off; + bool fragment; int err = -EPROTO; + fragment = false; + off = sizeof(struct iphdr); header_size = skb->network_header + off + MAX_IPOPTLEN; maybe_pull_tail(skb, header_size); + if (ntohs(iph->frag_off...
2011 Mar 28
5
[PATCH 1/3] Only peek and discard packets from specified device.
...it. + * Fetches a bootp packet from specified device, but doesn't remove it. * Returns: * 0 = Error * >0 = A packet of size "ret" is available for interface ifindex */ -int packet_peek(int *ifindex) +int packet_peek(struct netdev *dev) { struct sockaddr_ll sll; struct iphdr iph; int ret, sllen = sizeof(struct sockaddr_ll); + sll.sll_ifindex = dev->ifindex; /* * Peek at the IP header. */ @@ -192,21 +193,22 @@ int packet_peek(int *ifindex) if (iph.ihl < 5 || iph.version != IPVERSION) goto discard_pkt; - *ifindex = sll.sll_ifindex; return ret...
2003 Dec 26
2
[Bug 84] Unaligned access in ip_tables.c:ip_packet_match
...gers an ugly crash on m68k-nommu. This patch fixes all the symptoms I am seeing. --- linux-2.4.orig/net/ipv4/netfilter/ip_tables.c 2003-12-26 12:13:58.000000000 +0200 +++ linux-2.4/net/ipv4/netfilter/ip_tables.c 2003-12-26 12:11:01.000000000 +0200 @@ -151,11 +151,11 @@ ip_packet_match(const struct iphdr *ip, } /* Look for ifname matches; this should unroll nicely. */ - for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) { - ret |= (((const unsigned long *)indev)[i] - ^ ((const unsigned long *)ipinfo->iniface)[i]) - & ((const unsigned long *)ipinfo->iniface_mas...
2005 Oct 14
5
[PATCH] Fix NAT for domU checksum offload
...ntohs(range->max.tcp.port) - min + 1; + } + + for (i = 0; i < range_size; i++, port++) { + *portptr = htons(min + port % range_size); + if (!ip_nat_used_tuple(tuple, conntrack)) { + return 1; + } + } + return 0; +} + +static int +tcp_manip_pkt(struct sk_buff **pskb, + unsigned int iphdroff, + const struct ip_conntrack_tuple *tuple, + enum ip_nat_manip_type maniptype) +{ + struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff); + struct tcphdr *hdr; + unsigned int hdroff = iphdroff + iph->ihl*4; + u32 oldip, newip; + u16 *portptr, newport, oldport; + int h...
2011 Mar 27
4
ipconfig problem if multiple devices are up
Hi, it seems that ipconfig has a problem if multiple devices are up and connected to the same network. It seems that it uses the wrong socket/device index to compare it to incoming packet. To be more precise, the packet gets discarded in do_pkt_recv as the ifindex from state differs always from the incoming packet To reproduce create two tap devices: $ sudo tunctl -u uli -t tap0
2007 Apr 18
6
[Bridge] No UDP NFS over bridges in Linux 2.6.16.x?
Hi, I have 2 servers which are connected to a gateway machine. The gateway and one server are running Linux 2.6.16.2, while the third machine is running 2.6.16.5. The two ethernet ports on the gateway which are connected to the servers are combined into a single ethernet bridge device. Ever since 2.6.16, I have noticed that I can no longer cross-mount the two servers' /home directories via
2003 Apr 29
0
[PATCH] Fix busy-looping behaviour in ipconfig
...}; int i, len = 0; + if (local_port != LOCAL_PORT) { + ipudp_hdrs.udp.source = htons(local_port); + ipudp_hdrs.udp.dest = htons(remote_port); + } + /* * Glue in the ip+udp header iovec */ @@ -160,11 +169,21 @@ return 0; discard_pkt: - recvfrom(pkt_fd, &iph, sizeof(struct iphdr), - 0, (struct sockaddr *)&sll, &sllen); + packet_discard(); return 0; } +void packet_discard(void) +{ + struct iphdr iph; + struct sockaddr_ll sll; + socklen_t sllen = sizeof(sll); + + recvfrom(pkt_fd, &iph, sizeof(iph), 0, + (struct sockaddr *) &sll, &sllen); +} + +...
2017 Feb 04
0
[PATCH] ipconfig: handle multiple interfaces correctly
...0, + recvfrom(dev->pkt_fd, &iph, sizeof(iph), 0, (struct sockaddr *)&sll, &sllen); } @@ -207,7 +214,7 @@ int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len) msg.msg_name = &sll; msg.msg_namelen = sllen; - ret = recvfrom(pkt_fd, &iph, sizeof(struct iphdr), + ret = recvfrom(dev->pkt_fd, &iph, sizeof(struct iphdr), MSG_PEEK, (struct sockaddr *)&sll, &sllen); if (ret == -1) return -1; @@ -226,7 +233,7 @@ int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len) iov[0].iov_base = ip; iov[0].iov_len = iphl + s...
2004 Sep 06
0
example/dsmark+policing => tcsim outputs are different
...cing - Dsmark with tcindex and policing * * Packets with non-zero TOS/DS field are marked with TOS 0xb8 (EF DSCP). * If they exceed the rate limit, they''re dropped. */ #define TOS_ZERO UDP_HDR($ip_tos=0) #define TOS_NONZERO UDP_HDR($ip_tos=1) #define PAYLOAD 0 x 980 /* 1000-sizeof(iphdr) = 980 bytes */ dev eth0 10000 { /* 10 Mbps */ #include "dsmark+policing.tc" } every 0.005s send TOS_ZERO PAYLOAD /* 1.6 Mbps */ every 0.005s send TOS_NONZERO PAYLOAD /* 1.6 Mbps */ time 2s end >>> ---------- end of dsmark+policing.tcsim file: ---------- >>>...
2003 Aug 02
1
[SECURITY] Netfilter Security Advisory: NAT Remote DOS (SACK mangle)
...if sack found and adjuste= d */ -static inline int +/* TCP SACK sequence number adjustment. */ +static inline void ip_nat_sack_adjust(struct sk_buff *skb, - struct ip_conntrack *ct, - enum ip_conntrack_info ctinfo) + struct ip_conntrack *ct, + enum ip_conntrack_info ctinfo) { - struct iphdr *iph; struct tcphdr *tcph; - unsigned char *ptr; - int length, dir, sack_adjusted =3D 0; + unsigned char *ptr, *optend; + unsigned int dir; =20 - iph =3D skb->nh.iph; - tcph =3D (void *)iph + iph->ihl*4; - length =3D (tcph->doff*4)-sizeof(struct tcphdr); + tcph =3D (void *)skb->nh.iph...
2019 Jan 18
0
[klibc:master] ipconfig: handle multiple interfaces correctly
...0, + recvfrom(dev->pkt_fd, &iph, sizeof(iph), 0, (struct sockaddr *)&sll, &sllen); } @@ -207,7 +214,7 @@ int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len) msg.msg_name = &sll; msg.msg_namelen = sllen; - ret = recvfrom(pkt_fd, &iph, sizeof(struct iphdr), + ret = recvfrom(dev->pkt_fd, &iph, sizeof(struct iphdr), MSG_PEEK, (struct sockaddr *)&sll, &sllen); if (ret == -1) return -1; @@ -226,7 +233,7 @@ int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len) iov[0].iov_base = ip; iov[0].iov_len = iphl + s...
2008 Jun 14
2
PATCH: ipconfig may discard useful packets
...but doesn't remove it. + * Returns: + * 0 = Error + * >0 = A packet of size "ret" is available for interface ifindex + */ int packet_peek(int *ifindex) { struct sockaddr_ll sll; @@ -177,7 +183,7 @@ int packet_peek(int *ifindex) ret = recvfrom(pkt_fd, &iph, sizeof(struct iphdr), MSG_PEEK, (struct sockaddr *)&sll, &sllen); if (ret == -1) - return -1; + return 0; if (sll.sll_family != AF_PACKET) goto discard_pkt; @@ -187,7 +193,7 @@ int packet_peek(int *ifindex) *ifindex = sll.sll_ifindex; - return 0; + return ret; discard_pkt: packet_di...
2010 Jun 28
3
[PATCHv2] vhost-net: add dhclient work-around from userspace
...* so we add a work-around just for DHCP. */ + if (skb->ip_summed == CHECKSUM_PARTIAL && + skb_headlen(skb) >= skb_transport_offset(skb) + + sizeof(struct udphdr) && + udp_hdr(skb)->dest == htons(68) && + skb_network_header_len(skb) >= sizeof(struct iphdr) && + ip_hdr(skb)->protocol == IPPROTO_UDP && + skb->protocol == htons(ETH_P_IP)) { + skb_checksum_help(skb); + /* Restore ip_summed value: tun passes it to user. */ + skb->ip_summed = CHECKSUM_PARTIAL; + } + release_sock(sk); + return 1; +} + /* Expects to be a...
2010 Jun 28
3
[PATCHv2] vhost-net: add dhclient work-around from userspace
...* so we add a work-around just for DHCP. */ + if (skb->ip_summed == CHECKSUM_PARTIAL && + skb_headlen(skb) >= skb_transport_offset(skb) + + sizeof(struct udphdr) && + udp_hdr(skb)->dest == htons(68) && + skb_network_header_len(skb) >= sizeof(struct iphdr) && + ip_hdr(skb)->protocol == IPPROTO_UDP && + skb->protocol == htons(ETH_P_IP)) { + skb_checksum_help(skb); + /* Restore ip_summed value: tun passes it to user. */ + skb->ip_summed = CHECKSUM_PARTIAL; + } + release_sock(sk); + return 1; +} + /* Expects to be a...
2020 Mar 28
0
[klibc:master] ipconfig: Fix alignment of packet structure
...insertion(+), 1 deletion(-) diff --git a/usr/kinit/ipconfig/packet.c b/usr/kinit/ipconfig/packet.c index 20018010..2e1487d2 100644 --- a/usr/kinit/ipconfig/packet.c +++ b/usr/kinit/ipconfig/packet.c @@ -86,7 +86,7 @@ static unsigned int ip_checksum(uint16_t *hdr, int len) struct header { struct iphdr ip; struct udphdr udp; -} __attribute__ ((packed)); +} __attribute__ ((packed, aligned(4))); static struct header ipudp_hdrs = { .ip = {
2009 Mar 12
1
the return value of packet_peek()
...I can avoiding ipconfig fall in a loop with icmp packet, like this: --- /work/atcs/os_pkg/klibc-git/klibc/usr/kinit/ipconfig.old/packet.c 2009-03-11 15:30:45.000000000 +0800 +++ packet.c 2009-03-11 17:39:56.000000000 +0800 @@ -176,6 +176,8 @@ */ ret = recvfrom(pkt_fd, &iph, sizeof(struct iphdr), MSG_PEEK, (struct sockaddr *)&sll, &sllen); + + if (ret == -1) return -1; @@ -184,6 +186,10 @@ if (iph.ihl < 5 || iph.version != IPVERSION) goto discard_pkt; + + if (iph.protocol != IPPROTO_UDP) + goto discard_pkt; + *ifindex = sll.sll_ifindex; @@ -1...