Comments (4)
Hi, maybe RFC1624 - Computation of the Internet Checksum via Incremental Update could help you ?
from sbulb.
Hi, maybe RFC1624 - Computation of the Internet Checksum via Incremental Update could help you ?
Hi, I wrote a function to update the udp checksum according to the formula HC' = HC - ~m - m'
in RFC1624
, but it is still wrong, can you help me?
thanks
typedef union {
struct {
u16 ip1;
u16 ip2;
};
u32 ip;
} ip_num;
static __always_inline void udp_checksum_update(struct iphdr *old_iph, struct iphdr *iph, struct udphdr *old_udp, struct udphdr *udph)
{
// ip
ip_num old_src_ip, new_src_ip, old_dst_ip, new_dst_ip;
old_src_ip.ip = old_iph->saddr;
new_src_ip.ip = iph->saddr;
old_dst_ip.ip = old_iph->daddr;
new_dst_ip.ip = iph->daddr;
// port
u16 old_src_port = old_udp->source, new_src_port = udph->source;
u16 old_dst_port = old_udp->dest, new_dst_port = udph->dest;
// calc checksum
u16 new_csum = old_udp->check;
// src ip
new_csum = new_csum - (~old_src_ip.ip1) - new_src_ip.ip1;
new_csum = new_csum - (~old_src_ip.ip2) - new_src_ip.ip2;
// dest ip
new_csum = new_csum - (~old_dst_ip.ip1) - new_dst_ip.ip1;
new_csum = new_csum - (~old_dst_ip.ip2) - new_dst_ip.ip2;
// src port
new_csum = new_csum - (~old_src_port) - new_src_port;
// dest port
new_csum = new_csum - (~old_dst_port) - new_dst_port;
udph->check = new_csum;
}
from sbulb.
Did you also looked at : https://github.com/AirVantage/sbulb/blob/master/sbulb/bpf/checksum.c
from sbulb.
Did you also looked at :
master
/sbulb/bpf/checksum.c
@sbernard31 thanks
I misunderstood this function before, thinking that this function restricted u32, now my code has been changed to the following, and the verification has passed.
static __always_inline void udp_checksum_update(struct iphdr *old_iph, struct iphdr *iph, struct udphdr *old_udp, struct udphdr *udph)
{
u16 new_csum = old_udp->check;
update_csum(&new_csum, old_iph->saddr, iph->saddr);
update_csum(&new_csum, old_iph->daddr, iph->daddr);
update_csum(&new_csum, old_udp->source, udph->source);
update_csum(&new_csum, old_udp->dest, udph->dest);
udph->check = new_csum;
return;
}
from sbulb.
Related Issues (20)
- consider to use python type hints syntax
- Move repository to Sierra wireless organization HOT 1
- Choose a License 📃 HOT 1
- Handle TTL field from IP header. HOT 3
- Support IP option and so dynamic size of IP header HOT 1
- Support IP Fragmentation/Reassembling
- Add a new CLI option to set CFLAG
- Improve logging HOT 2
- Reloading the configuration on demand
- Notify systemd if sbulb managed to start successfuly
- Add units tests if possible ? HOT 1
- Add support to IPv6 HOT 3
- Verify behavior description of egress traffic HOT 7
- problem of bcc HOT 1
- Make the maximum "association" allowed configurable HOT 2
- Cleanning code HOT 1
- Use "incremental update" to calculate IP checksum like we do for UDP checksum HOT 1
- From "round-robin" to "random-pick" ?
- Experiment stateless loadbalancing using DTLS connection ID HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbulb.