]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/OSPF-ALIGNMENT.txt
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / ospfd / OSPF-ALIGNMENT.txt
CommitLineData
996ac2dc 1Greg Troxel <gdt@ir.bbn.com>
22004-11-17
3
4The OSPF specification (RFC2328) and the OSPF Opaque LSA specification
5(RFC2370) are ambiguous about LSAs whose data section is not an
6integral multiple of 4 octets. This note examines the issue and
7proposes clarifications to ensure interoperability.
8
9RFC2328 does not specify that LSA lengths be a multiple of 4.
10It does not require that LSAs in update packets be aligned.
11However, all structures defined by RFC2328 are multiples of 4, and
12thus update packets with those structures must be aligned.
13LSA length is defined in Appendix A.4 as
14
15 length
16 The length in bytes of the LSA. This includes the 20 byte LSA
17 header.
18
19RFC2370 defines Opaque LSAs, which are intended to contain arbitrary
20data:
21
22 This memo defines enhancements to the OSPF protocol to support a new
23 class of link-state advertisements (LSA) called Opaque LSAs. Opaque
24 LSAs provide a generalized mechanism to allow for the future
25 extensibility of OSPF. Opaque LSAs consist of a standard LSA header
26 followed by application-specific information. The information field
27 may be used directly by OSPF or by other applications. Standard OSPF
28 link-state database flooding mechanisms are used to distribute Opaque
29 LSAs to all or some limited portion of the OSPF topology.
30
31
32Later, 2370 says:
33
34 Opaque LSAs contain some number of octets (of application-specific
35 data) padded to 32-bit alignment.
36
37This can be interpreted in several ways:
38
39A) The payload may be any number of octets, and the length field
40reflects the payload length (e.g. length 23 for 3 octets of payload),
41but there are padding octets following the LSA in packets, so that the
42next LSA starts on a 4-octet boundary. (This approach is common in
43the BSD user/kernel interface.)
44
45B) The payload must be a multiple of 4 octets, so that the length is a
46multiple of 4 octets. This corresponds to an implementation that
47treats an Opaque LSA publish request that is not a multiple of 4
48octets as an error.
49
50C) The payload can be any number of octets, but padding is added and
51included in the length field. This interpretation corresponds to an
52OSPF implementation that accepts a publish request for an Opaque LSA
53that is not a multiple of 4 octets. This interpretation is
54nonsensical, because it claims to represent arbitrary lengths, but
55does not actually do so --- the receiver cannot distinguish padding
56from supplied data.
57
58D) Accept according to A, and transmit according to B.
59
60Option A arguably violates RFC 2328, which doesn't say anything about
61adding padding (A.3.5 shows a diagram of adjacent LSAs which are shown
62as all multiples of 4). This option is thus likely to lead to a lack
63of interoperability.
64
65Option B restricts what data can be represented as an Opaque LSA, but
66probably not in a serious way. It is likely to lead to
67interoperability in that the complex case of non-multiple-of-4 lengths
68will not arise.
69
70However, an implementation that follows A and emits an LSA with
71payload length not a multiple of 4 will not interoperate with an
72Option B implementation.
73
74Given that all known and documented uses of Opaque LSAs seem to be
75multiples of 4 octets, we choose Option B as the clarification.
76
77CLARIFYING TEXT
78
79In RFC2328:
80
81In section A.4, add a second sentence about length:
82
83 length
84 The length in bytes of the LSA. This includes the 20 byte LSA
85 header. The length must be an integral multiple of 4 bytes.
86
87Add to the list in Section 13:
88
89 Verify that the length of the LSA is a multiple of 4 bytes. If
90 not, discard the entire Link State Update Packet.
91
92In RFC2380:
93
94Change text:
95
96 Opaque LSAs contain some number of octets (of application-specific
97 data) padded to 32-bit alignment.
98
99to:
100
101 Opaque LSAs contain some a number of octets (of
102 application-specific data). The number of octets must be a
103 multiple of four.
104
105
106HOW THIS ISSUE AROSE
107
108At BBN, we use Opaque LSAs to exchange data among routers; the format
109of the data is naturally aligned to 4 bytes, and thus does not raise
110this issue. We created a test program to publish Opaque data via IPC
111to the OSPF daemon (quagga), and this program accepts strings on the
112command line to publish. We then used this test program to publish
113software version strings. Quagga's ospfd then crashed on a
114NetBSD/sparc64 machine with an alignment fault, because the odd-length
115LSAs were marshalled into a link-state update packet with no padding.
116While this behavior was a clear violation of RFC2380, it was not clear
117how to remedy the problem.