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