Hi,
I might understand what you explain by modified code.
1. original logic:
static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) {
f = fq_classify(skb, q);
if (fq_flow_is_detached(f)) {
fq_flow_add_tail(&q->new_flows, f);
if(...) {
smp_store_release(&sk->sk_pacing_status,SK_PACING_FQ);
}
}
}
static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q) {
root = &q->fq_root[hash_ptr(sk, q->fq_trees_log)];
p = &root->rb_node;
while(*p) {
if(f->sk == sk)
return f;
}
f = kmem_cache_zalloc;
fq_flow_set_detached(f);
rb_insert(f);
return f;
}
2. modified logic:
static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) {
f = fq_classify(skb, q);
if (fq_flow_is_detached(f)) {
fq_flow_add_tail(&q->new_flows, f);
...
}
}
static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q) {
root = &q->fq_root[hash_ptr(sk, q->fq_trees_log)];
p = &root->rb_node;
while(*p) {
if(f->sk == sk)
return f;
}
f = kmem_cache_zalloc;
fq_flow_set_detached(f);
if (skb->sk == sk)
smp_store_release(&sk->sk_pacing_status,SK_PACING_FQ);
rb_insert(f);
return f;
}
what does “a socket structure has been reallocated” mean? Two different sk have the same sk addr when first sk is destroyed but second sk alloc first sk's addr?
if it's right,
a. in original logic, the stale flow is f which returne from the red position “return f” is not detached, because f->next is NULL,which not be same as &detached,
so fq_enqueue can not set sk_pacing_status SK_PACING_FQ because fq_flow_is_detached return false.
My question is that how to insert the fq_flow to new_flows and how to send this skb, fq_flow_add_tail(&q->new_flows, f) can not be exec because fq_flow_is_detached return false too.
b. in fq_classify, fq_root will insert a invalid sk addr(sk = (struct sock *)((hash << 1) | 1UL)) when sending synack, tcp_v4_syn_recv_sock will create a new sock of child after recving ack of handshake, so the new sock must not be
the same as sk of synack, what is the point of doing this?
c. socket might have been reallocated, does request_sock(TCPF_NEW_SYN_RECV) and sock(TCP_ESTABLISHED) have the same problem?
I am not well with the tcp stack, I am sorry that t
hese questions may be a bit too simple for you.