From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hannes Eder Subject: Re: [PATCH 1/3] netfilter: xt_ipvs (netfilter matcher for IPVS) Date: Wed, 2 Sep 2009 17:33:12 +0200 Message-ID: References: <20090902101417.11561.45663.stgit@jazzy.zrh.corp.google.com> <20090902101527.11561.59498.stgit@jazzy.zrh.corp.google.com> <4A9E8711.1070807@trash.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, =?ISO-8859-1?Q?Fabien_Duch=EAne?= , Jan Engelhardt , Jean-Luc Fortemaison , Julian Anastasov , Julius Volz , Laurent Grawet , Simon Horman , Wensong Zhang To: Patrick McHardy Return-path: In-Reply-To: <4A9E8711.1070807@trash.net> Sender: linux-kernel-owner@vger.kernel.org List-Id: netfilter-devel.vger.kernel.org On Wed, Sep 2, 2009 at 16:54, Patrick McHardy wrote: > Hannes Eder wrote: >> This implements the kernel-space side of the netfilter matcher >> xt_ipvs. > > Looks mostly fine to me, just one question: > >> +bool ipvs_mt(const struct sk_buff *skb, const struct xt_match_param= *par) >> +{ >> + =A0 =A0 const struct xt_ipvs *data =3D par->matchinfo; >> + =A0 =A0 const u_int8_t family =3D par->family; >> + =A0 =A0 struct ip_vs_iphdr iph; >> + =A0 =A0 struct ip_vs_protocol *pp; >> + =A0 =A0 struct ip_vs_conn *cp; >> + =A0 =A0 int af; >> + =A0 =A0 bool match =3D true; >> + >> + =A0 =A0 if (data->bitmask =3D=3D XT_IPVS_IPVS_PROPERTY) { >> + =A0 =A0 =A0 =A0 =A0 =A0 match =3D skb->ipvs_property ^ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 !!(data->invert & XT_IPVS_= IPVS_PROPERTY); >> + =A0 =A0 =A0 =A0 =A0 =A0 goto out; >> + =A0 =A0 } >> + >> + =A0 =A0 /* other flags than XT_IPVS_IPVS_PROPERTY are set */ >> + =A0 =A0 if (!skb->ipvs_property) { >> + =A0 =A0 =A0 =A0 =A0 =A0 match =3D false; >> + =A0 =A0 =A0 =A0 =A0 =A0 goto out; >> + =A0 =A0 } >> + >> + =A0 =A0 switch (skb->protocol) { >> + =A0 =A0 case =A0htons(ETH_P_IP): >> + =A0 =A0 =A0 =A0 =A0 =A0 af =3D AF_INET; >> + =A0 =A0 =A0 =A0 =A0 =A0 break; >> +#ifdef CONFIG_IP_VS_IPV6 >> + =A0 =A0 case =A0htons(ETH_P_IPV6): >> + =A0 =A0 =A0 =A0 =A0 =A0 af =3D AF_INET6; >> + =A0 =A0 =A0 =A0 =A0 =A0 break; >> +#endif >> + =A0 =A0 default: >> + =A0 =A0 =A0 =A0 =A0 =A0 match =3D false; >> + =A0 =A0 =A0 =A0 =A0 =A0 goto out; >> + =A0 =A0 } > > In the NF_INET_LOCAL_OUT hook skb->protocol is invalid. So if you > don't need this, it would make sense to restrict the match to the > other hooks. > > Even easier would be to use par->family, which contains the address > family and doesn't need any translation. Nice, I'll use par->family. So in theory I do not even need a check like the following in the begin= ning? if (family !=3D NFPROTO_IPV4 #ifdef CONFIG_IP_VS_IPV6 && family !=3D NFPROTO_IPV6 #endif ) { match =3D false; goto out; } Thanks, -Hannes