lkml.org 
[lkml]   [2015]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH nf-next] netfilter: nf_ct_sctp: minimal multihoming support
On Tue, Jul 14, 2015 at 03:42:03PM +0200, Florian Westphal wrote:
> Michal Kubecek <mkubecek@suse.cz> wrote:
> > + case SCTP_CID_HEARTBEAT:
> > + pr_debug("SCTP_CID_HEARTBEAT");
> > + i = 9;
> > + break;
> > + case SCTP_CID_HEARTBEAT_ACK:
> > + pr_debug("SCTP_CID_HEARTBEAT_ACK");
> > + i = 10;
> > + break;
> > default:
> > /* Other chunks like DATA, SACK, HEARTBEAT and
> > its ACK do not cause a change in state */
> > @@ -329,6 +351,8 @@ static int sctp_packet(struct nf_conn *ct,
> > !test_bit(SCTP_CID_COOKIE_ECHO, map) &&
> > !test_bit(SCTP_CID_ABORT, map) &&
> > !test_bit(SCTP_CID_SHUTDOWN_ACK, map) &&
> > + !test_bit(SCTP_CID_HEARTBEAT, map) &&
> > + !test_bit(SCTP_CID_HEARTBEAT_ACK, map) &&
> > sh->vtag != ct->proto.sctp.vtag[dir]) {
> > pr_debug("Verification tag check failed\n");
> > goto out;
> > @@ -357,6 +381,16 @@ static int sctp_packet(struct nf_conn *ct,
> > /* Sec 8.5.1 (D) */
> > if (sh->vtag != ct->proto.sctp.vtag[dir])
> > goto out_unlock;
> > + } else if (sch->type == SCTP_CID_HEARTBEAT ||
> > + sch->type == SCTP_CID_HEARTBEAT_ACK) {
> > + if (ct->proto.sctp.vtag[dir] == 0) {
> > + pr_debug("Setting vtag %x for dir %d\n",
> > + sh->vtag, dir);
> > + ct->proto.sctp.vtag[dir] = sh->vtag;
>
> Could you please elaborate on the [dir] == 0 test?
>
> I see this might happen for SCTP_CID_HEARTBEAT_ACK, but why is this
> needed for SCTP_CID_HEARTBEAT ?
>
> We found a conntrack entry so shouldn't the vtag[dir] already be > 0?

Yes, you are right. This was originally intended to handle the case when
a HEARTBEAT in the reply direction is seen before the HEARTBEAT-ACK but
such HEARTBEAT would be dropped anyway in current version.

On the other hand, an alternative would be

} else if (sch->type == SCTP_CID_HEARTBEAT_ACK &&
ct->proto.sctp.vtag[dir] == 0) {
pr_debug("Setting vtag %x for dir %d\n",
sh->vtag, dir);
ct->proto.sctp.vtag[dir] = sh->vtag;
} else if ((sch->type == SCTP_CID_HEARTBEAT ||
sch->type == SCTP_CID_HEARTBEAT_ACK) &&
sh->vtag != ct->proto.sctp.vtag[dir]) {
pr_debug("Verification tag check failed\n");
goto out_unlock;
}

I'm not sure it looks better.

Michal Kubecek


\
 
 \ /
  Last update: 2015-07-14 19:01    [W:0.521 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site