OSPF area default-cost is a 16-bit quantity

The area area default-cost number router configuration command changes the cost of the default route advertised into a stub or NSSA area. IOS documentation claims the cost is a 24-bit number (and both type-3 and type-5/7 LSAs have 24 bits available for the metric), but in reality the router accepts a 24-bit number and remembers the lower 16 bits, potentially resulting in quite unexpected behavior (just try setting the OSPF costs to 30000 on one ABR and 70000 on another).

Update (2008-08-08): This behavior is reported as bug CSCsl12946 and fixed in IOS release 12.4(20)T.

Here is a sample printout taken from a router running IOS release 12.4(15)T5; 12.2(33)SRC behaves identically.
A1(config)#router ospf 1
A1(config-router)#area 11 default-cost 65538

A1#show running | sect router ospf
router ospf 1
 log-adjacency-changes
 area 11 stub
 area 11 default-cost 2

A1#show ip ospf 1 database summary 0.0.0.0

            OSPF Router with ID (10.0.1.1) (Process ID 1)

                Summary Net Link States (Area 11)

  LS age: 16
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 0.0.0.0 (summary Network Number)
  Advertising Router: A1
  LS Seq Number: 80000005
  Checksum: 0x4CE0
  Length: 28
  Network Mask: /0
        TOS: 0  Metric: 2 

6 comments:

  1. Smells of bug. Opened a TAC case for it ?

    ReplyDelete
  2. I think there is already an internal bug on this, which is not accessible to anyone except TAC. The bug says that the commands accepts values higher than its maximum value as per the command reference which is 65535.

    If you enter a value below or equal to 65535 it works fine, the problem happens when you take a value above that. If you do that it takes the (value)Mod(65535)-1

    So if you enter 'area 11 default-cost 65536', in 'show run' it wouid show up as 'area 11 default-cost 0'

    Here is what I did on my lab:
    ospf 1
    log-adjacency-changes
    area 11 stub
    area 11 default-cost 65532
    Rack1R1#conf t
    Rack1R1(config)#router ospf 1
    Rack1R1(config-router)#no area 11 default-cost 65532
    Rack1R1(config-router)#area 11 defaul
    Rack1R1(config-router)#area 11 default-cost 65535
    Rack1R1(config-router)#end
    Rack1R1#sh run | s r ospf
    router ospf 1
    log-adjacency-changes
    area 11 stub
    area 11 default-cost 65535
    Rack1R1#conf t
    Rack1R1(config)#router ospf 1
    Rack1R1(config-router)#no area 11 default-cost 65535
    Rack1R1(config-router)#area 11 default-cost 65536
    Rack1R1(config-router)#end
    Rack1R1#sh run | s r ospf
    router ospf 1
    log-adjacency-changes
    area 11 stub
    area 11 default-cost 0
    Rack1R1#

    ReplyDelete
  3. Tarun, your description is correct, but not the root cause analysis. The "metric" field in the OSPF summary and external LSA is 24 bit, so you should be able to specify a 24-bit value for the default cost in stub default and external default case.

    Furthermore, the documentation states that the cost is 24-bit quantity (which is correct), but IOS incorrectly accepts only the lower 16 bits of the entered cost.

    If you have access to the bug tools, please make sure they fix the bug the right way (i.e. accepting 24-bit numbers, not limiting the range to 16-bit numbers).

    ReplyDelete
  4. I opened CSCsr60041 to have this fixed.

    ReplyDelete
  5. this is fixed in CSCsl12946

    ReplyDelete
  6. Thanks, updated now to fix this bug! Been googling for this.

    ReplyDelete

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.