From: =?koi8-r?B?58HX0snMz9cg6cfP0tg=?= Date: Fri, 04 Dec 2015 16:00:34 +0000 Subject: Re: Problem with cls_flow nfct-* keys Message-Id: <570921449244834@web5h.yandex.ru> List-Id: References: <3419281448878074@web15j.yandex.ru> In-Reply-To: <3419281448878074@web15j.yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: lartc@vger.kernel.org After day after the day of trials and errors I finally get working solution= - I use code from act_connmark and it's working pretty well.=20 #define CTTUPLE(skb, member) \ ({ \ enum ip_conntrack_info ctinfo; \ struct nf_conntrack_tuple tuple; \ struct nf_conntrack_zone zone; \ const struct nf_conntrack_tuple_hash *thash; \ int proto; \ const struct nf_conn *ct =3D nf_ct_get(skb, &ctinfo); \ if (ct =3D NULL){ \ switch (tc_skb_protocol(skb)) { \ case htons(ETH_P_IP): \ proto =3D NFPROTO_IPV4; \ break; \ case htons(ETH_P_IPV6): \ proto =3D NFPROTO_IPV6; \ break; \ default: goto fallback; \ } \ if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), proto, &tuple)= ) \ goto fallback; \ zone.id =3D NF_CT_DEFAULT_ZONE_ID; \ zone.dir =3D NF_CT_DEFAULT_ZONE_DIR; \ \ thash =3D nf_conntrack_find_get(dev_net(skb->dev), &zone, &tuple);\ if (!thash) goto fallback; \ ct =3D nf_ct_tuplehash_to_ctrack(thash);} \ ct->tuplehash[CTINFO2DIR(ctinfo)].tuple.member; \ }) I can get info about original src/dst on ingress. But there is a little pro= blem in function ct->tuplehash[CTINFO2DIR(ctinfo)].tuple.member; I can't get valid direction, because I don't get ctinfo. Is any solustion f= or my situation? 03.12.2015, 12:51, "Andy Furniss" : > =E7=C1=D7=D2=C9=CC=CF=D7 =E9=C7=CF=D2=D8 wrote: >> =9ASo this problem not related to my setup. Seems that it occurs for a >> =9Along time. Is there any possibility to fix this, and what is the >> =9Areason of such behavior. > > As Florian says on ingress tc gets the packet before conntrack. > > I was slightly hopeful that I was wrong (in thinking this never worked) > when I saw "nf_ct_get" in the code, but it just looks at the skb which > on ingress won't have the fields filled in. > > /* Return conntrack_info and tuple hash for given skb. */ > static inline struct nf_conn * > nf_ct_get(const struct sk_buff *skb, enum ip_conntrack_info *ctinfo) > { > =9A=9A=9A=9A=9A=9A=9A=9A=9A*ctinfo =3D skb->nfctinfo; > =9A=9A=9A=9A=9A=9A=9A=9A=9Areturn (struct nf_conn *)skb->nfct; > } > > Historically at least people used imq to get at traffic after netfilter. > It seems it's still alive - > > www.linuximq.net > > but you need to patch kernel/iptables. > > When ifb first appeared it was mentioned that an action could be made to > get netfilter state and Florian mentions act_connmark.c so I guess some > progress was made. > > Not really much use for your example I suppose.