Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
v1shnya opened this issue Jan 20, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@v1shnya
Copy link

v1shnya commented Jan 20, 2023

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;
@TimEvens
Copy link
Contributor

TimEvens commented Feb 1, 2023

@v1shnya, Thanks. They can be added to the ip_rib_log table. While they are not there now, a log entry will be added because the rib hash ID includes those values in the hash.

@TimEvens TimEvens added the enhancement New feature or request label Feb 1, 2023
@TimEvens TimEvens self-assigned this Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants