Subject: Re: [quicwg/base-drafts] Change packet types (#1655)

From: Martin Thomson <[email-masked]>
Date: Fri, 14 Sep 2018 07:24:03 +0000 (UTC)

This one turns out to be tricky.  The question of where 0-RTT packets sit is a problem of competing concerns.  If we want to be nice to SRTP, it would be good to put Retry and 0-RTT on 0b10xx.xxxx (because those are unlikely to be of use in typical usage of SRTP).  On the other hand, here we have a request to put Initial and 0-RTT on 0b11xx.xxxx.  Noting that we are likely to use the remaining bits of the octet for many other things, maybe we can refine the proposal.

If we were to put Initial and 0-RTT adjacent in a different way, I think we can address all the concerns.

How bad is this test: `(pkt_type & 0xc0 != 0x80)` ?  I don't think that turns into any more instructions than `pkt_type < 0xfe`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/issues/1655#issuecomment-421256413

---

From: MikkelFJ <[email-masked]>
Date: Fri, 14 Sep 2018 00:53:56 -0700

`((int8_t)pkt_type + (int8_t)0x40) < 0`

The add operation should overflow and set the sign if the two upper bits are set and not in any other case. clang x64 does it slightly different using a cmp 0x40 followed by a conditional set in the example below, but that could be a conditional jump. 

```
#include <stdint.h>
#include <stdio.h>

int test(uint8_t pkt_type)
{
    int8_t x = (int8_t)pkt_type;
    return (x + (int8_t)0x40) < 0;
}
```
clang -c -S -O3 test.c

```
    .section    __TEXT,__text,regular,pure_instructions
    .macosx_version_min 10, 13
    .globl  _test                   ## -- Begin function test
    .p2align    4, 0x90
_test:                                  ## @test
    .cfi_startproc
## BB#0:
    pushq   %rbp
Lcfi0:
    .cfi_def_cfa_offset 16
Lcfi1:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Lcfi2:
    .cfi_def_cfa_register %rbp
    xorl    %eax, %eax
    cmpb    $-64, %dil
    setl    %al
    popq    %rbp
    retq
    .cfi_endproc
                                        ## -- End function

.subsections_via_symbols
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/issues/1655#issuecomment-421263469

---

From: MikkelFJ <[email-masked]>
Date: Fri, 14 Sep 2018 01:29:19 -0700

This above was tesing for 0b11xxxxxx
Testing for 0xb10xxxxxx
requires one extra and instruction following clang

```
#include <stdint.h>

uint8_t test(uint8_t pkt_type)
{
    return (pkt_type & 0xc0) != 0x80;
}
```

```

    andb    $-64, %dil
    xorl    %eax, %eax
    cmpb    $-128, %dil
    setne   %al
    popq    %rbp
    retq
    .cfi_endproc
                                        ## -- End function

.subsections_via_symbols
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/issues/1655#issuecomment-421272229

---

From: Udip Pant <[email-masked]>
Date: Mon, 17 Sep 2018 07:04:23 -0700

(pkt_type & 0xc0 != 0x80) should be fine. But curious about your type grouping that results in this (with first MSB for long header, you'd still just be using the second MSB here).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/issues/1655#issuecomment-422029800

---

From: Martin Thomson <[email-masked]>
Date: Tue, 18 Sep 2018 14:05:17 +0000 (UTC)

I'll go through this tomorrow, but the short answer is that we need to balance this with the need to multiplex with RTP.  (The final equation we settled on was `t & 0xa0 != 0x80`, the c was an error.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/issues/1655#issuecomment-422406045