Skip to content

sliceable switch cannot handle 64bit dpid with MSB set #22

@amotoki

Description

@amotoki

16桁のDPIDを登録すると、DPID の下位の桁が失われてしまう。

sqliteは、unsigned bigint と書いても 63ビットを超えるとfloatにするような動きをしている。

dpidのカラムは、unsigned bigintで定義されていますが、
sqliteでは、INTEGER(符号付き64bit)として取り扱われるため
2 ^ 63 以上の値を格納する際に型が変わり値が丸められるようです。

16桁のDPIDを利用してスライスにポートをバインディング

[root@ofcrm001 sliceable_switch]# ./slice add-port slice003 0xabcdef0000000031 17 0xffff nodrp013
A port is added successfully.
[root@ofcrm001 sliceable_switch]# ./slice show slice003
[Description]

[Port-based bindings]
ID Datapath ID Port VID
nodrp013 0xabcdef0000000000 17 65535

[MAC-based bindings]
No bindings found.

[MAC-based bindings on ports]
No bindings found.

結果、上記の通りDatapath IDが、0xabcdef0000000031ではなく、0xabcdef0000000000となってしまいます。

sqlite3 の問題だと思います。
同じコマンドを実行してみましたが、以下のようになりました。
また、sqlite3 で直接 INSERT をしても同じ現象になりましたので。

64bit dpid を使用する場合は backend DB として sqlite3 を利用するように
変更すべきでしょう。 Sliceable switch はサンプルアプリの位置付けのため、
手軽に利用できる sqlite3 を使っています。
本格的に利用する場合はそのあたりを直す必要があります。

$ sqlite3 ../../var/db/slice.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
bindings slices
sqlite> .header on
sqlite> .schema slices;
sqlite> .schema slices
CREATE TABLE slices (
number unsigned smallint not null,
id text not null,
description text,
constraint number_unique unique (number) on conflict fail,
constraint id_unique unique (id) on conflict fail
);
sqlite> select * from slices;
number|id|description
1|6da2d726-a852-47b1-ab03-6e842a85394e|ID=6da2d726-a852-47b1-ab03-6e842a85394e Name=net1 at Quantum.
2|17c038ad-55d1-4876-b4a7-6dca762966b3|ID=17c038ad-55d1-4876-b4a7-6dca762966b3 Name=ext_net at Quantum.
sqlite> select * from bindings;
type|datapath_id|port|vid|mac|id|slice_number
1|33270089032258|1|65535||64216194-f4df-4e9b-a84b-a4b88ebbb071|1
1|33270089032258|2|65535||bcd062b8-3c36-46c1-aa53-8721a188a45e|1
1|1.23798137339904e+19|17|65535||abcdef0000000031:0011:ffff|1
sqlite> INSERT INTO bindings (type,datapath_id,port,vid,slice_number,id) values (1,12379813733990400049,19,65535,1,'abcdef0000000031:0013:ffff');
sqlite> select * from bindings;
type|datapath_id|port|vid|mac|id|slice_number
1|33270089032258|1|65535||64216194-f4df-4e9b-a84b-a4b88ebbb071|1
1|33270089032258|2|65535||bcd062b8-3c36-46c1-aa53-8721a188a45e|1
1|1.23798137339904e+19|17|65535||abcdef0000000031:0011:ffff|1
1|1.23798137339904e+19|19|65535||abcdef0000000031:0013:ffff|1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions