Skip to content

Prefix History doesn't separate between AdjRIB-IN/OUT and Pre/Post-policy updates for the same prefix #9

@v1shnya

Description

@v1shnya

In the file "1_base.sql" the table ip_rib contains isPrePolicy and isAdjRibIn fields

CREATE TABLE ip_rib (
.....
    isPrePolicy             boolean             NOT NULL DEFAULT true,
    isAdjRibIn              boolean             NOT NULL DEFAULT true,
);

At same time, the table ip_rib_log lacks those fields, should be added

CREATE TABLE ip_rib_log (
    id                      bigserial           NOT NULL,
	base_attr_hash_id       uuid                NOT NULL,
	timestamp               timestamp(6)        without time zone default (now() at time zone 'utc') NOT NULL,
    peer_hash_id            uuid                NOT NULL,
    prefix                  inet                NOT NULL,
    prefix_len              smallint            NOT NULL,
    origin_as               bigint              NOT NULL,
    isWithdrawn             boolean             NOT NULL
) TABLESPACE timeseries;

v_ip_routes_history as dependent on ip_rib_log should also containthose fields, file "8_views.sql"

And, update function of ip_rib_log table, file "9_triggers.sql", should include new.isPrePolicy and new.isAdjRibIn values!

CREATE OR REPLACE FUNCTION t_ip_rib_update()
	RETURNS trigger AS $$
BEGIN
	IF (new.isWithdrawn) THEN
		INSERT INTO ip_rib_log (isWithdrawn,prefix,prefix_len,base_attr_hash_id,peer_hash_id,origin_as,timestamp)
		VALUES (true,new.prefix,new.prefix_len,old.base_attr_hash_id,new.peer_hash_id,
		        old.origin_as,new.timestamp);
	ELSE
		INSERT INTO ip_rib_log (isWithdrawn,prefix,prefix_len,base_attr_hash_id,peer_hash_id,origin_as,timestamp)
		VALUES (false,new.prefix,new.prefix_len,new.base_attr_hash_id,new.peer_hash_id,
		        new.origin_as,new.timestamp);
	END IF;

	RETURN NEW;
END;
$$ LANGUAGE plpgsql;

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions