* [PATCH net] net/sched: act_ct: fix restore the qdisc_skb_cb after defrag
@ 2020-07-18 11:34 wenxu
2020-07-18 12:30 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: wenxu @ 2020-07-18 11:34 UTC (permalink / raw)
To: fw, xiyou.wangcong; +Cc: netdev
From: wenxu <wenxu@ucloud.cn>
The fragment packets do defrag in tcf_ct_handle_fragments
will clear the skb->cb which make the qdisc_skb_cb clear
too. So the qdsic_skb_cb should be store before defrag and
restore after that.
It also update the pkt_len after all the
fragments finish the defrag to one packet and make the
following actions counter correct.
Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
This patch resend followup with
"http://patchwork.ozlabs.org/project/netdev/cover/1594097711-9365-1-git-send-email-wenxu@ucloud.cn/"
net/sched/act_ct.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 67504ae..e675e2d 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -676,6 +676,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
u8 family, u16 zone)
{
enum ip_conntrack_info ctinfo;
+ struct qdisc_skb_cb cb;
struct nf_conn *ct;
int err = 0;
bool frag;
@@ -693,6 +694,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
return err;
skb_get(skb);
+ cb = *qdisc_skb_cb(skb);
if (family == NFPROTO_IPV4) {
enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
@@ -717,6 +719,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
#endif
}
+ *qdisc_skb_cb(skb) = cb;
skb_clear_hash(skb);
skb->ignore_df = 1;
return err;
@@ -1014,6 +1017,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
out:
tcf_action_update_bstats(&c->common, skb);
+ qdisc_skb_cb(skb)->pkt_len = skb->len;
return retval;
drop:
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net/sched: act_ct: fix restore the qdisc_skb_cb after defrag
2020-07-18 11:34 [PATCH net] net/sched: act_ct: fix restore the qdisc_skb_cb after defrag wenxu
@ 2020-07-18 12:30 ` Florian Westphal
2020-07-19 1:31 ` wenxu
0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2020-07-18 12:30 UTC (permalink / raw)
To: wenxu; +Cc: fw, xiyou.wangcong, netdev
wenxu@ucloud.cn <wenxu@ucloud.cn> wrote:
> From: wenxu <wenxu@ucloud.cn>
>
> The fragment packets do defrag in tcf_ct_handle_fragments
> will clear the skb->cb which make the qdisc_skb_cb clear
> too. So the qdsic_skb_cb should be store before defrag and
> restore after that.
> It also update the pkt_len after all the
> fragments finish the defrag to one packet and make the
> following actions counter correct.
>
> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
> Signed-off-by: wenxu <wenxu@ucloud.cn>
Looks ok to me. One question:
> @@ -1014,6 +1017,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
>
> out:
> tcf_action_update_bstats(&c->common, skb);
> + qdisc_skb_cb(skb)->pkt_len = skb->len;
> return retval;
This appears to be unconditional, I would have expected that
this only done for reassembled skbs?
Otherwise we will lose the value calculated by core via
qdisc_calculate_pkt_len().
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net/sched: act_ct: fix restore the qdisc_skb_cb after defrag
2020-07-18 12:30 ` Florian Westphal
@ 2020-07-19 1:31 ` wenxu
0 siblings, 0 replies; 3+ messages in thread
From: wenxu @ 2020-07-19 1:31 UTC (permalink / raw)
To: Florian Westphal; +Cc: xiyou.wangcong, netdev
在 2020/7/18 20:30, Florian Westphal 写道:
> wenxu@ucloud.cn <wenxu@ucloud.cn> wrote:
>> From: wenxu <wenxu@ucloud.cn>
>>
>> The fragment packets do defrag in tcf_ct_handle_fragments
>> will clear the skb->cb which make the qdisc_skb_cb clear
>> too. So the qdsic_skb_cb should be store before defrag and
>> restore after that.
>> It also update the pkt_len after all the
>> fragments finish the defrag to one packet and make the
>> following actions counter correct.
>>
>> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
>> Signed-off-by: wenxu <wenxu@ucloud.cn>
> Looks ok to me. One question:
>
>> @@ -1014,6 +1017,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
>>
>> out:
>> tcf_action_update_bstats(&c->common, skb);
>> + qdisc_skb_cb(skb)->pkt_len = skb->len;
>> return retval;
> This appears to be unconditional, I would have expected that
> this only done for reassembled skbs?
Yes.
>
> Otherwise we will lose the value calculated by core via
> qdisc_calculate_pkt_len().
qdisc_calculate_pkt_len only be cablled in dev_xmit_skb and qdisc_enqueue. If all the fragment will
pass those before defrag, it will caculate correctly. If the reassembled packets pass those, it also caculate correctly after we recaculate the pkt_len of qdisc_skb_cb
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-19 1:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-18 11:34 [PATCH net] net/sched: act_ct: fix restore the qdisc_skb_cb after defrag wenxu
2020-07-18 12:30 ` Florian Westphal
2020-07-19 1:31 ` wenxu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).