[qca-nss-clients] Verify ingress shaping rule entries.
Change-Id: I1c44ebdbfe9b84940ce01f9e6fe31a90c75c9489
Signed-off-by: Manish Verma <maniverm@codeaurora.org>
diff --git a/netlink/nss_nlipv4.c b/netlink/nss_nlipv4.c
index ba6a9de..d1cf730 100644
--- a/netlink/nss_nlipv4.c
+++ b/netlink/nss_nlipv4.c
@@ -494,6 +494,29 @@
}
/*
+ * nss_nlipv4_verify_igs_rule()
+ * Verify and override ingress shaping rule entries.
+ */
+static int nss_nlipv4_verify_igs_rule(struct nss_ipv4_rule_create_msg *msg)
+{
+ struct nss_ipv4_igs_rule *igs = &msg->igs_rule;
+ const size_t rule_sz = sizeof(struct nss_ipv4_igs_rule);
+ bool valid;
+
+ valid = msg->valid_flags & NSS_IPV4_RULE_CREATE_IGS_VALID;
+
+ /*
+ * ingress shaping rule is not valid ignore rest of the checks
+ */
+ if (!valid) {
+ memset(igs, 0, rule_sz);
+ return 0;
+ }
+
+ return 0;
+}
+
+/*
* nss_nlipv4_verify_dscp_rule()
* verify and override dscp rule entries
*/
@@ -728,6 +751,15 @@
}
/*
+ * check ingress shaping rule
+ */
+ error = nss_nlipv4_verify_igs_rule(&nim->msg.rule_create);
+ if (error < 0) {
+ nss_nl_error("%d:invalid ingress shaping rule information passed\n", pid);
+ goto done;
+ }
+
+ /*
* check dscp rule
*/
error = nss_nlipv4_verify_dscp_rule(&nim->msg.rule_create);
diff --git a/netlink/nss_nlipv6.c b/netlink/nss_nlipv6.c
index e01060b..1d49bce 100644
--- a/netlink/nss_nlipv6.c
+++ b/netlink/nss_nlipv6.c
@@ -472,6 +472,27 @@
}
/*
+ * nss_nlipv6_verify_igs_rule()
+ * verify and override ingress shaping rule entries
+ */
+static int nss_nlipv6_verify_igs_rule(struct nss_ipv6_rule_create_msg *msg)
+{
+ struct nss_ipv6_igs_rule *igs = &msg->igs_rule;
+ const size_t rule_sz = sizeof(struct nss_ipv6_igs_rule);
+ bool valid;
+
+ /*
+ * ingress shaping rule is not valid ignore rest of the checks
+ */
+ valid = msg->valid_flags & NSS_IPV6_RULE_CREATE_IGS_VALID;
+ if (!valid) {
+ memset(igs, 0, rule_sz);
+ return 0;
+ }
+ return 0;
+}
+
+/*
* nss_nlipv6_verify_qos_rule()
* verify and override qos rule entries
*/
@@ -723,6 +744,15 @@
}
/*
+ * check ingress shaping rule
+ */
+ error = nss_nlipv6_verify_igs_rule(&nim->msg.rule_create);
+ if (error < 0) {
+ nss_nl_error("%d:invalid ingress shaping rule information passed\n", pid);
+ goto done;
+ }
+
+ /*
* check dscp rule
*/
error = nss_nlipv6_verify_dscp_rule(&nim->msg.rule_create);