We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Bug] GENEVE.post_build() compute 'optionlen' incorrect
### Brief description

GENEVE.post_build() compute 'optionlen' incorrect.

I found that 'optionlen' always incorrect, when I implement class `GeneveOptINT` for (In-band Network Telemetry (INT)),.

Finally I found that `BitField("optionlen", None, 6)` the 'optionlen' is a 6bits field,
The tmp_len mask should be 0x3f instead of 0x2f.

1.Current Implement:
```Python
class GENEVE(Packet):
    def post_build(self, p, pay):
        if self.optionlen is None:
            tmp_len = (len(p) - 8) // 4
            p = chb(tmp_len & 0x2f | orb(p[0]) & 0xc0) + p[1:]
        return p + pay
```

2.Fixed method:
```Python
class GENEVE(Packet):
    def post_build(self, p, pay):
        if self.optionlen is None:
            tmp_len = (len(p) - 8) // 4
            p = chb(tmp_len & 0x3f | orb(p[0]) & 0xc0) + p[1:]
        return p + pay
```


### Scapy version

2.5.0

### Python version

3.7

### Operating system

Linux 5.10.27-051027-generic

### Additional environment information

_No response_

### How to reproduce

```
hujf@4c4c2fcab3ca:/usr/lib/python3/dist-packages$ sudo scapy
>>> from scapy.contrib.geneve import *
>>> data_str='1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff'
>>> GENEVE(raw(GENEVE(options=GeneveOptions(data=data_str))))[GENEVE].optionlen
1
```

### Actual result

```
hujf@4c4c2fcab3ca:/usr/lib/python3/dist-packages$ sudo scapy
>>> from scapy.contrib.geneve import *
>>> data_str='1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff'
>>> GENEVE(raw(GENEVE(options=GeneveOptions(data=data_str))))[GENEVE].optionlen
1
```

### Expected result

```
hujf@a7a04dccbbb8:/localdata/hujf/asic-cosim$ sudo scapy
>>> from scapy.contrib.geneve import *
>>> data_str='1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff'
>>> GENEVE(raw(GENEVE(options=GeneveOptions(data=data_str))))[GENEVE].optionlen
17
>>> 
```

### Related resources

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scapy/contrib/geneve.py`
Content:
```
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # This file is part of Scapy
3 # See https://scapy.net/ for more information
4 # Copyright (C) 2018 Hao Zheng <haozheng10@gmail.com>
5 
6 # scapy.contrib.description = Generic Network Virtualization Encapsulation (GENEVE)
7 # scapy.contrib.status = loads
8 
9 """
10 Geneve: Generic Network Virtualization Encapsulation
11 
12 draft-ietf-nvo3-geneve-16
13 """
14 
15 import struct
16 
17 from scapy.fields import BitField, XByteField, XShortEnumField, X3BytesField, StrLenField, PacketListField
18 from scapy.packet import Packet, bind_layers
19 from scapy.layers.inet import IP, UDP
20 from scapy.layers.inet6 import IPv6
21 from scapy.layers.l2 import Ether, ETHER_TYPES
22 from scapy.compat import chb, orb
23 
24 CLASS_IDS = {0x0100: "Linux",
25              0x0101: "Open vSwitch",
26              0x0102: "Open Virtual Networking (OVN)",
27              0x0103: "In-band Network Telemetry (INT)",
28              0x0104: "VMware",
29              0x0105: "Amazon.com, Inc.",
30              0x0106: "Cisco Systems, Inc.",
31              0x0107: "Oracle Corporation",
32              0x0110: "Amazon.com, Inc.",
33              0x0118: "IBM",
34              0x0128: "Ericsson",
35              0xFEFF: "Unassigned",
36              0xFFFF: "Experimental"}
37 
38 
39 class GeneveOptions(Packet):
40     name = "Geneve Options"
41     fields_desc = [XShortEnumField("classid", 0x0000, CLASS_IDS),
42                    XByteField("type", 0x00),
43                    BitField("reserved", 0, 3),
44                    BitField("length", None, 5),
45                    StrLenField('data', '', length_from=lambda x:x.length * 4)]
46 
47     def post_build(self, p, pay):
48         if self.length is None:
49             tmp_len = len(self.data) // 4
50             p = p[:3] + struct.pack("!B", tmp_len) + p[4:]
51         return p + pay
52 
53 
54 class GENEVE(Packet):
55     name = "GENEVE"
56     fields_desc = [BitField("version", 0, 2),
57                    BitField("optionlen", None, 6),
58                    BitField("oam", 0, 1),
59                    BitField("critical", 0, 1),
60                    BitField("reserved", 0, 6),
61                    XShortEnumField("proto", 0x0000, ETHER_TYPES),
62                    X3BytesField("vni", 0),
63                    XByteField("reserved2", 0x00),
64                    PacketListField("options", [], GeneveOptions, length_from=lambda pkt:pkt.optionlen * 4)]
65 
66     def post_build(self, p, pay):
67         if self.optionlen is None:
68             tmp_len = (len(p) - 8) // 4
69             p = chb(tmp_len & 0x2f | orb(p[0]) & 0xc0) + p[1:]
70         return p + pay
71 
72     def answers(self, other):
73         if isinstance(other, GENEVE):
74             if ((self.proto == other.proto) and (self.vni == other.vni)):
75                 return self.payload.answers(other.payload)
76         else:
77             return self.payload.answers(other)
78         return 0
79 
80     def mysummary(self):
81         return self.sprintf("GENEVE (vni=%GENEVE.vni%,"
82                             "optionlen=%GENEVE.optionlen%,"
83                             "proto=%GENEVE.proto%)")
84 
85 
86 bind_layers(UDP, GENEVE, dport=6081)
87 bind_layers(GENEVE, Ether, proto=0x6558)
88 bind_layers(GENEVE, IP, proto=0x0800)
89 bind_layers(GENEVE, IPv6, proto=0x86dd)
90
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scapy/contrib/geneve.py b/scapy/contrib/geneve.py
--- a/scapy/contrib/geneve.py
+++ b/scapy/contrib/geneve.py
@@ -66,7 +66,7 @@
     def post_build(self, p, pay):
         if self.optionlen is None:
             tmp_len = (len(p) - 8) // 4
-            p = chb(tmp_len & 0x2f | orb(p[0]) & 0xc0) + p[1:]
+            p = chb(tmp_len & 0x3f | orb(p[0]) & 0xc0) + p[1:]
         return p + pay
 
     def answers(self, other):

{"golden_diff": "diff --git a/scapy/contrib/geneve.py b/scapy/contrib/geneve.py\n--- a/scapy/contrib/geneve.py\n+++ b/scapy/contrib/geneve.py\n@@ -66,7 +66,7 @@\n     def post_build(self, p, pay):\n         if self.optionlen is None:\n             tmp_len = (len(p) - 8) // 4\n-            p = chb(tmp_len & 0x2f | orb(p[0]) & 0xc0) + p[1:]\n+            p = chb(tmp_len & 0x3f | orb(p[0]) & 0xc0) + p[1:]\n         return p + pay\n \n     def answers(self, other):\n", "issue": "[Bug] GENEVE.post_build() compute 'optionlen' incorrect\n### Brief description\n\nGENEVE.post_build() compute 'optionlen' incorrect.\r\n\r\nI found that 'optionlen' always incorrect, when I implement class `GeneveOptINT` for (In-band Network Telemetry (INT)),.\r\n\r\nFinally I found that `BitField(\"optionlen\", None, 6)` the 'optionlen' is a 6bits field,\r\nThe tmp_len mask should be 0x3f instead of 0x2f.\r\n\r\n1.Current Implement:\r\n```Python\r\nclass GENEVE(Packet):\r\n    def post_build(self, p, pay):\r\n        if self.optionlen is None:\r\n            tmp_len = (len(p) - 8) // 4\r\n            p = chb(tmp_len & 0x2f | orb(p[0]) & 0xc0) + p[1:]\r\n        return p + pay\r\n```\r\n\r\n2.Fixed method:\r\n```Python\r\nclass GENEVE(Packet):\r\n    def post_build(self, p, pay):\r\n        if self.optionlen is None:\r\n            tmp_len = (len(p) - 8) // 4\r\n            p = chb(tmp_len & 0x3f | orb(p[0]) & 0xc0) + p[1:]\r\n        return p + pay\r\n```\r\n\n\n### Scapy version\n\n2.5.0\n\n### Python version\n\n3.7\n\n### Operating system\n\nLinux 5.10.27-051027-generic\n\n### Additional environment information\n\n_No response_\n\n### How to reproduce\n\n```\r\nhujf@4c4c2fcab3ca:/usr/lib/python3/dist-packages$ sudo scapy\r\n>>> from scapy.contrib.geneve import *\r\n>>> data_str='1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff'\r\n>>> GENEVE(raw(GENEVE(options=GeneveOptions(data=data_str))))[GENEVE].optionlen\r\n1\r\n```\n\n### Actual result\n\n```\r\nhujf@4c4c2fcab3ca:/usr/lib/python3/dist-packages$ sudo scapy\r\n>>> from scapy.contrib.geneve import *\r\n>>> data_str='1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff'\r\n>>> GENEVE(raw(GENEVE(options=GeneveOptions(data=data_str))))[GENEVE].optionlen\r\n1\r\n```\n\n### Expected result\n\n```\r\nhujf@a7a04dccbbb8:/localdata/hujf/asic-cosim$ sudo scapy\r\n>>> from scapy.contrib.geneve import *\r\n>>> data_str='1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff'\r\n>>> GENEVE(raw(GENEVE(options=GeneveOptions(data=data_str))))[GENEVE].optionlen\r\n17\r\n>>> \r\n```\n\n### Related resources\n\n_No response_\n", "before_files": [{"content": "# SPDX-License-Identifier: GPL-2.0-or-later\n# This file is part of Scapy\n# See https://scapy.net/ for more information\n# Copyright (C) 2018 Hao Zheng <haozheng10@gmail.com>\n\n# scapy.contrib.description = Generic Network Virtualization Encapsulation (GENEVE)\n# scapy.contrib.status = loads\n\n\"\"\"\nGeneve: Generic Network Virtualization Encapsulation\n\ndraft-ietf-nvo3-geneve-16\n\"\"\"\n\nimport struct\n\nfrom scapy.fields import BitField, XByteField, XShortEnumField, X3BytesField, StrLenField, PacketListField\nfrom scapy.packet import Packet, bind_layers\nfrom scapy.layers.inet import IP, UDP\nfrom scapy.layers.inet6 import IPv6\nfrom scapy.layers.l2 import Ether, ETHER_TYPES\nfrom scapy.compat import chb, orb\n\nCLASS_IDS = {0x0100: \"Linux\",\n             0x0101: \"Open vSwitch\",\n             0x0102: \"Open Virtual Networking (OVN)\",\n             0x0103: \"In-band Network Telemetry (INT)\",\n             0x0104: \"VMware\",\n             0x0105: \"Amazon.com, Inc.\",\n             0x0106: \"Cisco Systems, Inc.\",\n             0x0107: \"Oracle Corporation\",\n             0x0110: \"Amazon.com, Inc.\",\n             0x0118: \"IBM\",\n             0x0128: \"Ericsson\",\n             0xFEFF: \"Unassigned\",\n             0xFFFF: \"Experimental\"}\n\n\nclass GeneveOptions(Packet):\n    name = \"Geneve Options\"\n    fields_desc = [XShortEnumField(\"classid\", 0x0000, CLASS_IDS),\n                   XByteField(\"type\", 0x00),\n                   BitField(\"reserved\", 0, 3),\n                   BitField(\"length\", None, 5),\n                   StrLenField('data', '', length_from=lambda x:x.length * 4)]\n\n    def post_build(self, p, pay):\n        if self.length is None:\n            tmp_len = len(self.data) // 4\n            p = p[:3] + struct.pack(\"!B\", tmp_len) + p[4:]\n        return p + pay\n\n\nclass GENEVE(Packet):\n    name = \"GENEVE\"\n    fields_desc = [BitField(\"version\", 0, 2),\n                   BitField(\"optionlen\", None, 6),\n                   BitField(\"oam\", 0, 1),\n                   BitField(\"critical\", 0, 1),\n                   BitField(\"reserved\", 0, 6),\n                   XShortEnumField(\"proto\", 0x0000, ETHER_TYPES),\n                   X3BytesField(\"vni\", 0),\n                   XByteField(\"reserved2\", 0x00),\n                   PacketListField(\"options\", [], GeneveOptions, length_from=lambda pkt:pkt.optionlen * 4)]\n\n    def post_build(self, p, pay):\n        if self.optionlen is None:\n            tmp_len = (len(p) - 8) // 4\n            p = chb(tmp_len & 0x2f | orb(p[0]) & 0xc0) + p[1:]\n        return p + pay\n\n    def answers(self, other):\n        if isinstance(other, GENEVE):\n            if ((self.proto == other.proto) and (self.vni == other.vni)):\n                return self.payload.answers(other.payload)\n        else:\n            return self.payload.answers(other)\n        return 0\n\n    def mysummary(self):\n        return self.sprintf(\"GENEVE (vni=%GENEVE.vni%,\"\n                            \"optionlen=%GENEVE.optionlen%,\"\n                            \"proto=%GENEVE.proto%)\")\n\n\nbind_layers(UDP, GENEVE, dport=6081)\nbind_layers(GENEVE, Ether, proto=0x6558)\nbind_layers(GENEVE, IP, proto=0x0800)\nbind_layers(GENEVE, IPv6, proto=0x86dd)\n", "path": "scapy/contrib/geneve.py"}], "after_files": [{"content": "# SPDX-License-Identifier: GPL-2.0-or-later\n# This file is part of Scapy\n# See https://scapy.net/ for more information\n# Copyright (C) 2018 Hao Zheng <haozheng10@gmail.com>\n\n# scapy.contrib.description = Generic Network Virtualization Encapsulation (GENEVE)\n# scapy.contrib.status = loads\n\n\"\"\"\nGeneve: Generic Network Virtualization Encapsulation\n\ndraft-ietf-nvo3-geneve-16\n\"\"\"\n\nimport struct\n\nfrom scapy.fields import BitField, XByteField, XShortEnumField, X3BytesField, StrLenField, PacketListField\nfrom scapy.packet import Packet, bind_layers\nfrom scapy.layers.inet import IP, UDP\nfrom scapy.layers.inet6 import IPv6\nfrom scapy.layers.l2 import Ether, ETHER_TYPES\nfrom scapy.compat import chb, orb\n\nCLASS_IDS = {0x0100: \"Linux\",\n             0x0101: \"Open vSwitch\",\n             0x0102: \"Open Virtual Networking (OVN)\",\n             0x0103: \"In-band Network Telemetry (INT)\",\n             0x0104: \"VMware\",\n             0x0105: \"Amazon.com, Inc.\",\n             0x0106: \"Cisco Systems, Inc.\",\n             0x0107: \"Oracle Corporation\",\n             0x0110: \"Amazon.com, Inc.\",\n             0x0118: \"IBM\",\n             0x0128: \"Ericsson\",\n             0xFEFF: \"Unassigned\",\n             0xFFFF: \"Experimental\"}\n\n\nclass GeneveOptions(Packet):\n    name = \"Geneve Options\"\n    fields_desc = [XShortEnumField(\"classid\", 0x0000, CLASS_IDS),\n                   XByteField(\"type\", 0x00),\n                   BitField(\"reserved\", 0, 3),\n                   BitField(\"length\", None, 5),\n                   StrLenField('data', '', length_from=lambda x:x.length * 4)]\n\n    def post_build(self, p, pay):\n        if self.length is None:\n            tmp_len = len(self.data) // 4\n            p = p[:3] + struct.pack(\"!B\", tmp_len) + p[4:]\n        return p + pay\n\n\nclass GENEVE(Packet):\n    name = \"GENEVE\"\n    fields_desc = [BitField(\"version\", 0, 2),\n                   BitField(\"optionlen\", None, 6),\n                   BitField(\"oam\", 0, 1),\n                   BitField(\"critical\", 0, 1),\n                   BitField(\"reserved\", 0, 6),\n                   XShortEnumField(\"proto\", 0x0000, ETHER_TYPES),\n                   X3BytesField(\"vni\", 0),\n                   XByteField(\"reserved2\", 0x00),\n                   PacketListField(\"options\", [], GeneveOptions, length_from=lambda pkt:pkt.optionlen * 4)]\n\n    def post_build(self, p, pay):\n        if self.optionlen is None:\n            tmp_len = (len(p) - 8) // 4\n            p = chb(tmp_len & 0x3f | orb(p[0]) & 0xc0) + p[1:]\n        return p + pay\n\n    def answers(self, other):\n        if isinstance(other, GENEVE):\n            if ((self.proto == other.proto) and (self.vni == other.vni)):\n                return self.payload.answers(other.payload)\n        else:\n            return self.payload.answers(other)\n        return 0\n\n    def mysummary(self):\n        return self.sprintf(\"GENEVE (vni=%GENEVE.vni%,\"\n                            \"optionlen=%GENEVE.optionlen%,\"\n                            \"proto=%GENEVE.proto%)\")\n\n\nbind_layers(UDP, GENEVE, dport=6081)\nbind_layers(GENEVE, Ether, proto=0x6558)\nbind_layers(GENEVE, IP, proto=0x0800)\nbind_layers(GENEVE, IPv6, proto=0x86dd)\n", "path": "scapy/contrib/geneve.py"}]}