From: Julien Vehent <julien@linuxwall.info>
To: netfilter <netfilter@vger.kernel.org>
Subject: Re: SFQ hash question
Date: Fri, 11 Sep 2009 17:03:58 +0200 [thread overview]
Message-ID: <e0153ce6b4a20009e99b7abf9fdd4498@localhost> (raw)
In-Reply-To: <0322d4853c39162f0819db9263a210ed@localhost>
On Fri, 11 Sep 2009 15:50:45 +0200, Julien Vehent <julien@linuxwall.info>
wrote:
> Hi there,
>
> Since LARTC is down, I believe the best place to ask traffic control
> questions is here.
> I hope you guys won't mind...
>
> I was reading the code of SFQ, and since I'm no C expert I don't
> understand exactly on what the hash is computed:
>
>
> -------
> static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
> {
> u32 h, h2;
>
> switch (skb->protocol) {
> case htons(ETH_P_IP):
> {
> const struct iphdr *iph = ip_hdr(skb);
> h = iph->daddr;
> h2 = iph->saddr ^ iph->protocol;
> if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
> (iph->protocol == IPPROTO_TCP ||
> iph->protocol == IPPROTO_UDP ||
> iph->protocol == IPPROTO_UDPLITE ||
> iph->protocol == IPPROTO_SCTP ||
> iph->protocol == IPPROTO_DCCP ||
> iph->protocol == IPPROTO_ESP))
> h2 ^= *(((u32*)iph) + iph->ihl);
> break;
> }
> ------
>
> OK for "h" and h2" before the "if", but what does this "if
> (!(iph->frag_off&htons(IP_MF|IP_OFFSET))" really does?
>
> And, also, I'm not sure about this: "h2 ^= *(((u32*)iph) + iph->ihl);"
>
> Does it XOR h2 with the first 32 bits of the L4 protocol header ?
>
Sorry for the noise... just read the man page and it's actually explained
there.
-----
On enqueueing, each packet is assigned to a hash bucket, based on
(i) Source address
(ii) Destination address
(iii) Source port
If these are available. SFQ knows about ipv4 and ipv6 and also UDP, TCP
and ESP. Packets with other protocols are hashed based on the 32bits
representation of their destination and the socket they belong to. A flow
corresponds mostly to a TCP/IP connection.
-----
>
> Thanks,
> Julien
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-09-11 15:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-11 13:50 SFQ hash question Julien Vehent
2009-09-11 15:03 ` Julien Vehent [this message]
2009-09-11 15:12 ` Michal Soltys
[not found] ` <2643b2d5a75307da3d00e97e0245bcf9@localhost>
[not found] ` <4AAA70A4.8030707@ziu.info>
2009-09-11 15:53 ` Julien Vehent
2009-09-12 22:12 ` Michal Soltys
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e0153ce6b4a20009e99b7abf9fdd4498@localhost \
--to=julien@linuxwall.info \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.