From: =?big5?B?qkzgSK54?= Subject: why we need find_appopriate_src? rether than just check in_range? Date: Fri, 5 Dec 2003 11:40:31 +0800 Sender: netfilter-devel-admin@lists.netfilter.org Message-ID: <001301c3bae1$88c362e0$2501a8c0@murphy> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0010_01C3BB24.967BAC10" Return-path: To: Errors-To: netfilter-devel-admin@lists.netfilter.org List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: List-Id: netfilter-devel.vger.kernel.org This is a multi-part message in MIME format. ------=_NextPart_000_0010_01C3BB24.967BAC10 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable 1.find_appropriate_src(const struct ip_conntrack_tuple *tuple, const struct ip_nat_multi_range *mr) { unsigned int h =3D hash_by_src(&tuple->src, tuple->dst.protonum); struct ip_nat_hash *i; MUST_BE_READ_LOCKED(&ip_nat_lock); i =3D LIST_FIND(&bysource[h], src_cmp, struct ip_nat_hash *, tuple, = mr); if (i) return &i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src; else return NULL; } static inline int src_cmp(const struct ip_nat_hash *i, const struct ip_conntrack_tuple *tuple, const struct ip_nat_multi_range *mr) { return (i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum =3D=3D tuple->dst.protonum && i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip =3D=3D tuple->src.ip && i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all =3D=3D tuple->src.u.all # ??? Is code marked by RED colour is somewhat a kind of pre-designed = idea for certain SECURITY mechanism, that is not clear so far ??? ... = Murphy Hsu-ting Lin ( Taiwan ) && in_range(tuple, &i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL] .tuple.src, mr)); } =20 ------=_NextPart_000_0010_01C3BB24.967BAC10 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
1.find_appropriate_src(const = struct=20 ip_conntrack_tuple *tuple,
       const = struct=20 ip_nat_multi_range *mr)
{
 unsigned int h =3D=20 hash_by_src(&tuple->src, tuple->dst.protonum);
 struct = ip_nat_hash *i;
 
 MUST_BE_READ_LOCKED(&ip_nat_lock);
 i =3D=20 LIST_FIND(&bysource[h], src_cmp, struct ip_nat_hash *, tuple,=20 mr);
 if (i)
  return=20 &i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src;
&nbs= p;else
  return=20 NULL;
}
 
static inline int
src_cmp(const struct = ip_nat_hash=20 *i,
 const struct ip_conntrack_tuple *tuple,
 const = struct=20 ip_nat_multi_range *mr)
{
 return=20 (i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum
=   =3D=3D=20 tuple->dst.protonum
  &&=20 i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip
 &= nbsp;=3D=3D=20 tuple->src.ip
  &&=20 i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all
&nbs= p; =3D=3D=20 tuple->src.u.all
# = ??? Is=20 code marked by RED colour  is somewhat a kind of = pre-designed=20 idea for certain SECURITY mechanism, that is not = clear so=20 far ??? ...   Murphy Hsu-ting Lin=20 ( Taiwan )
  &&=20 in_range(tuple,
      =20 &i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
  &nb= sp;   =20 .tuple.src,
       = mr));
}

 
 
 
 
 
 

 
------=_NextPart_000_0010_01C3BB24.967BAC10--