From 2f4f7dae495b0e1c2222d771f3252ca30e8fc22a Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 18 May 2021 02:42:05 -0400 Subject: [PATCH] import nispor-1.0.1-4.el8 --- .gitignore | 2 + .nispor.metadata | 2 + ...ort-to-vlan-srcmac-tx-hashing-option.patch | 47 + ...Z_1926941-remove-the-varlink-support.patch | 807 ++++++++++++++++++ SPECS/nispor.spec | 147 ++++ 5 files changed, 1005 insertions(+) create mode 100644 .gitignore create mode 100644 .nispor.metadata create mode 100644 SOURCES/BZ_1919986-bond-add-support-to-vlan-srcmac-tx-hashing-option.patch create mode 100644 SOURCES/BZ_1926941-remove-the-varlink-support.patch create mode 100644 SPECS/nispor.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..764784b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/nispor-1.0.1-vendor.tar.xz +SOURCES/nispor-1.0.1.tar.gz diff --git a/.nispor.metadata b/.nispor.metadata new file mode 100644 index 0000000..b96f15f --- /dev/null +++ b/.nispor.metadata @@ -0,0 +1,2 @@ +2af16151bd7a523bb228c3e0bb3462bf71b4a740 SOURCES/nispor-1.0.1-vendor.tar.xz +4a9585f8dd2ca52248dd8a26881b21e0cd104493 SOURCES/nispor-1.0.1.tar.gz diff --git a/SOURCES/BZ_1919986-bond-add-support-to-vlan-srcmac-tx-hashing-option.patch b/SOURCES/BZ_1919986-bond-add-support-to-vlan-srcmac-tx-hashing-option.patch new file mode 100644 index 0000000..3af2e0b --- /dev/null +++ b/SOURCES/BZ_1919986-bond-add-support-to-vlan-srcmac-tx-hashing-option.patch @@ -0,0 +1,47 @@ +From 32e5d0a2e217322e144fe1ffe916e217133c2b74 Mon Sep 17 00:00:00 2001 +From: Fernando Fernandez Mancera +Date: Mon, 25 Jan 2021 13:59:40 +0100 +Subject: [PATCH] bond: add support to vlan+srcmac tx hashing option + +The new vlan+srcmac tx hashing option is now available at kernel +upstream. Nispor should support it. + +Ref: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=7b8fc0103bb51d1d3e1fb5fd67958612e709f883 + +Signed-off-by: Fernando Fernandez Mancera +--- + src/lib/ifaces/bond.rs | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/lib/ifaces/bond.rs b/src/lib/ifaces/bond.rs +index d3a3b6c..63fafeb 100644 +--- a/src/lib/ifaces/bond.rs ++++ b/src/lib/ifaces/bond.rs +@@ -171,6 +171,7 @@ const BOND_XMIT_POLICY_LAYER34: u8 = 1; + const BOND_XMIT_POLICY_LAYER23: u8 = 2; + const BOND_XMIT_POLICY_ENCAP23: u8 = 3; + const BOND_XMIT_POLICY_ENCAP34: u8 = 4; ++const BOND_XMIT_POLICY_VLAN_SRCMAC: u8 = 5; + + #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] + #[serde(rename_all = "lowercase")] +@@ -185,6 +186,8 @@ pub enum BondXmitHashPolicy { + Encap23, + #[serde(rename = "encap3+4")] + Encap34, ++ #[serde(rename = "vlan+srcmac")] ++ VlanSrcMac, + Other(u8), + } + +@@ -196,6 +199,7 @@ impl From for BondXmitHashPolicy { + BOND_XMIT_POLICY_LAYER23 => Self::Layer23, + BOND_XMIT_POLICY_ENCAP23 => Self::Encap23, + BOND_XMIT_POLICY_ENCAP34 => Self::Encap34, ++ BOND_XMIT_POLICY_VLAN_SRCMAC => Self::VlanSrcMac, + _ => Self::Other(d), + } + } +-- +2.29.2 + diff --git a/SOURCES/BZ_1926941-remove-the-varlink-support.patch b/SOURCES/BZ_1926941-remove-the-varlink-support.patch new file mode 100644 index 0000000..0b8ff39 --- /dev/null +++ b/SOURCES/BZ_1926941-remove-the-varlink-support.patch @@ -0,0 +1,807 @@ +From 6655f63d3c8d5a551925a43b1fbf16a153a5c4cc Mon Sep 17 00:00:00 2001 +From: Fernando Fernandez Mancera +Date: Tue, 16 Feb 2021 12:06:18 +0100 +Subject: [PATCH] varlink: remove the varlink support + +There is no real user for varlink support on nispor. This patch is +removing the varlink support and all the documentation related to it. + +Signed-off-by: Fernando Fernandez Mancera +--- + Cargo.toml | 1 - + DEVEL.md | 5 - + Makefile | 35 +--- + README.md | 14 -- + src/varlink/Cargo.toml | 17 -- + src/varlink/info.nispor.varlink | 263 ----------------------------- + src/varlink/info_nispor.rs | 228 ------------------------- + src/varlink/npd.rs | 51 ------ + src/varlink/systemd/nispor.service | 10 -- + src/varlink/systemd/nispor.socket | 10 -- + 10 files changed, 5 insertions(+), 629 deletions(-) + delete mode 100644 src/varlink/Cargo.toml + delete mode 100644 src/varlink/info.nispor.varlink + delete mode 100644 src/varlink/info_nispor.rs + delete mode 100644 src/varlink/npd.rs + delete mode 100644 src/varlink/systemd/nispor.service + delete mode 100644 src/varlink/systemd/nispor.socket + +diff --git a/Cargo.toml b/Cargo.toml +index b03c824..59a55be 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -1,6 +1,5 @@ + [workspace] + members = [ +- "src/varlink", + "src/lib", + "src/cli", + "src/clib", +diff --git a/DEVEL.md b/DEVEL.md +index bd96064..0ebcc1f 100644 +--- a/DEVEL.md ++++ b/DEVEL.md +@@ -9,7 +9,6 @@ + * [Design](#design) + * [Rust module](#rust-module) + * [Command line tool](#command-line-tool) +- * [Varlink service](#varlink-service) + * [Python binding](#python-binding) + * [Check list for creating PR:](#check-list-for-creating-pr) + * [Release workflow](#release-workflow) +@@ -43,10 +42,6 @@ Path: `src/lib` + + Path: `src/cli` + +-### Varlink service +- +-Path: `src/varlink` +- + ### Python binding + + Path: `src/python` +diff --git a/Makefile b/Makefile +index b628944..2e92906 100644 +--- a/Makefile ++++ b/Makefile +@@ -2,9 +2,6 @@ include ./Makefile.inc + + RUST_DEBUG_BIN_DIR=./target/debug + RUST_RELEASE_BIN_DIR=./target/release +-VARLINK_SRV_EXEC=npd +-VARLINK_SRV_EXEC_DEBUG=$(RUST_DEBUG_BIN_DIR)/$(VARLINK_SRV_EXEC) +-VARLINK_SRV_EXEC_RELEASE=$(RUST_RELEASE_BIN_DIR)/$(VARLINK_SRV_EXEC) + CLI_EXEC=npc + CLI_EXEC_DEBUG=$(RUST_DEBUG_BIN_DIR)/$(CLI_EXEC) + CLIB_HEADER=nispor.h +@@ -18,8 +15,6 @@ CLI_EXEC_RELEASE=$(RUST_RELEASE_BIN_DIR)/$(CLI_EXEC) + SOCKET_FILE=/run/nispor/nispor.so + SOCKET_DIR=$(dir $(SOCKET_FILE)) + SOCKET_ADDR=unix:$(SOCKET_FILE) +-SYSTEMD_SERVICE_FILE=src/varlink/systemd/nispor.service +-SYSTEMD_SOCKET_FILE=src/varlink/systemd/nispor.socket + PREFIX ?= /usr/local + + CPU_BITS = $(shell getconf LONG_BIT) +@@ -34,8 +29,7 @@ PKG_CONFIG_LIBDIR ?= $(LIBDIR)/pkgconfig + + SKIP_PYTHON_INSTALL ?=0 + +-all: $(VARLINK_SRV_EXEC_DEBUG) $(CLI_EXEC_DEBUG) \ +- $(VARLINK_SRV_EXEC_RELEASE) $(CLI_EXEC_RELEASE) ++all: $(CLI_EXEC_DEBUG) $(CLI_EXEC_RELEASE) + + SYSTEMD_SYS_UNIT_DIR ?= $(shell \ + pkg-config --variable=systemdsystemunitdir systemd) +@@ -46,16 +40,16 @@ PYTHON3_SITE_DIR ?=$(shell \ + print(get_python_lib())") + + # Always invoke cargo build for debug +-.PHONY: $(VARLINK_SRV_EXEC_DEBUG) $(CLI_EXEC_DEBUG) ++.PHONY: $(CLI_EXEC_DEBUG) + + debug: $(CLI_EXEC_DEBUG) + $(CLI_EXEC_DEBUG) $(ARGS) + + +-$(CLI_EXEC_DEBUG) $(VARLINK_SRV_EXEC_DEBUG): ++$(CLI_EXEC_DEBUG): + cargo build --all + +-$(CLI_EXEC_RELEASE) $(VARLINK_SRV_EXEC_RELEASE) $(CLIB_SO_DEV_RELEASE): ++$(CLI_EXEC_RELEASE) $(CLIB_SO_DEV_RELEASE): + cargo build --all --release + + check: +@@ -65,30 +59,13 @@ check: + fi + make check -C test/clib + +-srv: $(VARLINK_SRV_EXEC_DEBUG) +- echo $(SOCKET_DIR) +- if [ ! -d $(SOCKET_DIR) ]; then \ +- sudo mkdir $(SOCKET_DIR); \ +- sudo chmod 0777 $(SOCKET_DIR); \ +- fi +- $(VARLINK_SRV_EXEC_DEBUG) $(SOCKET_ADDR) +- +-cli: +- varlink call $(SOCKET_ADDR)/info.nispor.Get +- + clean: + cargo clean + make clean -C test/clib + +-install: $(VARLINK_SRV_EXEC_RELEASE) $(CLI_EXEC_RELEASE) +- install -p -v -D -m755 $(VARLINK_SRV_EXEC_RELEASE) \ +- $(DESTDIR)$(PREFIX)/bin/$(VARLINK_SRV_EXEC) ++install: $(CLI_EXEC_RELEASE) + install -p -v -D -m755 $(CLI_EXEC_RELEASE) \ + $(DESTDIR)$(PREFIX)/bin/$(CLI_EXEC) +- install -p -v -D -m644 $(SYSTEMD_SOCKET_FILE) \ +- $(DESTDIR)$(SYSTEMD_SYS_UNIT_DIR)/nispor.socket +- install -p -D -m644 $(SYSTEMD_SERVICE_FILE) \ +- $(DESTDIR)$(SYSTEMD_SYS_UNIT_DIR)/nispor.service + install -p -D -m755 $(CLIB_SO_DEV_RELEASE) \ + $(DESTDIR)$(LIBDIR)/$(CLIB_SO_FULL) + ln -sfv $(CLIB_SO_FULL) $(DESTDIR)$(LIBDIR)/$(CLIB_SO_MAN) +@@ -120,9 +97,7 @@ install: $(VARLINK_SRV_EXEC_RELEASE) $(CLI_EXEC_RELEASE) + + + uninstall: +- - rm -fv $(DESTDIR)$(PREFIX)/bin/$(VARLINK_SRV_EXEC) + - rm -fv $(DESTDIR)$(PREFIX)/bin/$(CLI_EXEC) +- - rm -fv $(DESTDIR)$(SYSTEMD_SYS_UNIT_DIR)/nispor* + - rm -fv $(DESTDIR)$(LIBDIR)/$(CLIB_SO_DEV) + - rm -fv $(DESTDIR)$(LIBDIR)/$(CLIB_SO_MAN) + - rm -fv $(DESTDIR)$(LIBDIR)/$(CLIB_SO_MIN) +diff --git a/README.md b/README.md +index 4a50e5e..c1eda2c 100644 +--- a/README.md ++++ b/README.md +@@ -5,7 +5,6 @@ Currently providing: + * Rust crate + * Python binding + * C binding +- * Varlink interface -- `npd` + * Command line tool -- `npc` + + ## Install +@@ -35,19 +34,6 @@ npc bond99 + npc route + ``` + +-### Varlink service +- +-```bash +-systemctl start nispor.socket +-``` +- +-### Varlink client +- +-```bash +-# Please install `libvarlink-util` pacakge beforehand +-varlink call unix:/run/nispor/nispor.so/info.nispor.Get +-``` +- + ## Supported features + * IPv4/IPv6 address + * Bond +diff --git a/src/varlink/Cargo.toml b/src/varlink/Cargo.toml +deleted file mode 100644 +index c8775d4..0000000 +--- a/src/varlink/Cargo.toml ++++ /dev/null +@@ -1,17 +0,0 @@ +-[package] +-name = "npd" +-version = "1.0.1" +-authors = ["Gris Ge "] +-edition = "2018" +- +-[[bin]] +-name = "npd" +-path = "npd.rs" +- +-[dependencies] +-varlink = "11" +-serde = "1.0" +-serde_derive = "1.0" +-serde_json = "1.0" +-nispor = { path = "../lib" } +-libc = "0.2.71" +diff --git a/src/varlink/info.nispor.varlink b/src/varlink/info.nispor.varlink +deleted file mode 100644 +index cc9b7d4..0000000 +--- a/src/varlink/info.nispor.varlink ++++ /dev/null +@@ -1,263 +0,0 @@ +-interface info.nispor +- +-type BondInfo ( +- subordinates: []string, +- mode: []string, +- options: [string]string +-) +- +-type BridgeInfo ( +- stp_state: (disabled, kernel_stp, user_stp, unknown), +- hello_time: int, +- forward_delay: int, +- max_age: int, +- priority: int, +- subordinates: []string, +- ageing_time: int, +- bridge_id: string, +- group_fwd_mask: int, +- root_id: string, +- root_port: int, +- root_path_cost: int, +- topology_change: bool, +- topology_change_detected: bool, +- hello_timer: int, +- tcn_timer: int, +- topology_change_timer: int, +- multicast_router: (disabled, temp_query, perm, temp, unknown), +- multicast_snooping: bool, +- multicast_query_use_ifaddr: bool, +- multicast_querier: bool, +- multicast_stats_enabled: bool, +- multicast_hash_elasticity: int, +- multicast_hash_max: int, +- multicast_last_member_count: int, +- multicast_startup_query_count: int, +- multicast_last_member_interval: int, +- multicast_membership_interval: int, +- multicast_querier_interval: int, +- multicast_query_interval: int, +- multicast_query_response_interval: int, +- multicast_startup_query_interval: int, +- multicast_igmp_version: int, +- multicast_mld_version: int, +- gc_timer: int, +- group_addr: string, +- nf_call_iptables: bool, +- nf_call_ip6tables: bool, +- nf_call_arptables: bool, +- vlan_filtering: bool, +- vlan_protocol: (802.1q, 802.1ad), +- ?default_pvid: int, +-) +- +-type BridgeVlanEntry ( +- ?vid: int, +- ?vid_range: []int, +- is_pvid: bool, +- is_egress_untagged: bool, +-) +- +-type BridgePortInfo ( +- stp_state: (disabled, listening, learning, forwarding, blocking, unknown), +- stp_priority: int, +- stp_path_cost: int, +- hairpin_mode: bool, +- bpdu_guard: bool, +- root_block: bool, +- multicast_fast_leave: bool, +- learning: bool, +- unicast_flood: bool, +- proxyarp: bool, +- proxyarp_wifi: bool, +- designated_root: string, +- designated_bridge: string, +- designated_port: int, +- designated_cost: int, +- port_id: string, +- port_no: string, +- change_ack: bool, +- config_pending: bool, +- message_age_timer: int, +- forward_delay_timer: int, +- hold_timer: int, +- multicast_router: (disabled, temp_query, perm, temp, unknown), +- multicast_flood: bool, +- multicast_to_unicast: bool, +- vlan_tunnel: bool, +- broadcast_flood: bool, +- group_fwd_mask: int, +- neigh_suppress: bool, +- isolated: bool, +- ?backup_port: string, +- ?vlans: []BridgeVlanEntry, +-) +- +-type Ipv4Info ( +- addresses: []Ipv4AddrInfo +-) +- +-type Ipv4AddrInfo ( +- address: string, +- prefix_len: int, +- ?peer: string, +- valid_lft: string, +- preferred_lft: string +-) +- +-type Ipv6Info ( +- addresses: []Ipv6AddrInfo +-) +- +-type Ipv6AddrInfo ( +- address: string, +- prefix_len: int, +- valid_lft: string, +- preferred_lft: string +-) +- +-type VlanInfo ( +- vlan_id: int, +- protocol: (802.1q, 802.1ad, unknown), +- base_iface: string, +- is_reorder_hdr: bool, +- is_gvrp: bool, +- is_loose_binding: bool, +- is_mvrp: bool, +- is_bridge_binding: bool, +-) +- +-type VfState ( +- rx_packets: int, +- tx_packets: int, +- rx_bytes: int, +- tx_bytes: int, +- broadcast: int, +- multicast: int, +- rx_dropped: int, +- tx_dropped: int, +-) +- +-type VfInfo ( +- id: int, +- mac: string, +- broadcast: string, +- vlan_id: int, +- qos: int, +- tx_rate: int, +- spoof_check: int, +- link_state: (auto, enable, disable, unknown), +- min_tx_rate: int, +- max_tx_rate: int, +- query_rss: bool, +- state: VfState, +- trust: bool, +- ?ib_node_guid: string, +- ?ib_port_guid: string, +-) +- +-type SriovInfo ( +- vfs: []VfInfo, +-) +- +-type TunInfo ( +- mode: (tun, tap, unknown), +- pi: bool, +- vnet_hdr: bool, +- multi_queue: bool, +- persist: bool, +- ?owner: int, +- ?group: int, +- ?num_queues: int, +- ?num_disabled_queues: int, +-) +- +-type VethInfo ( +- peer: string, +-) +- +-type VxlanInfo ( +- remote: string, +- vxlan_id: int, +- base_iface: string, +- local: string, +- ttl: int, +- tos: int, +- learning: bool, +- ageing: int, +- max_address: int, +- src_port_min: int, +- src_port_max: int, +- proxy: bool, +- rsc: bool, +- l2miss: bool, +- l3miss: bool, +- dst_port: int, +- udp_check_sum: bool, +- udp6_zero_check_sum_tx: bool, +- udp6_zero_check_sum_rx: bool, +- remote_check_sum_tx: bool, +- remote_check_sum_rx: bool, +- gbp: bool, +- remote_check_sum_no_partial: bool, +- collect_metadata: bool, +- label: int, +- gpe: bool, +- ttl_inherit: bool, +- df: int, +-) +- +-type VrfInfo ( +- table_id: int, +- subordinates: []string, +-) +- +-type VrfSubordinateInfo ( +- table_id: int, +-) +- +-type MacVlanInfo ( +- base_iface: string, +- mode: (private, vepa, bridge, passthru, source, unknown), +- flags: int, +- ?allowed_mac_addresses: []string, +-) +- +-type MacVtapInfo ( +- base_iface: string, +- mode: (private, vepa, bridge, passthru, source, unknown), +- flags: int, +- ?allowed_mac_addresses: []string, +-) +- +-type Iface ( +- name: string, +- iface_type: string, +- state: (Up, Down, Unknown), +- mtu: int, +- ?bond: BondInfo, +- ?bond_subordinate: [string]string, +- ?bridge: BridgeInfo, +- ?bridge_port: BridgePortInfo, +- ?vlan: VlanInfo, +- ?vxlan: VxlanInfo, +- ?sriov: SriovInfo, +- ?tun: TunInfo, +- ?veth: VethInfo, +- ?vrf: VrfInfo, +- ?vrf_subordinate: VrfSubordinateInfo, +- ?mac_vlan: MacVlanInfo, +- ?mac_vtap: MacVtapInfo, +- ?controller: string, +- ?controller_type: (bond, unknown), +- ?ipv4: Ipv4Info, +- ?ipv6: Ipv6Info +-) +- +-type NetState ( +- ifaces: [string]Iface +-) +- +-method Get() -> (net_state: NetState) +- +-error InternalError(msg: string) +diff --git a/src/varlink/info_nispor.rs b/src/varlink/info_nispor.rs +deleted file mode 100644 +index 1d614b5..0000000 +--- a/src/varlink/info_nispor.rs ++++ /dev/null +@@ -1,228 +0,0 @@ +-#![doc = "This file was automatically generated by the varlink rust generator"] +-#![allow(non_camel_case_types)] +-#![allow(non_snake_case)] +-use nispor::NetState; +-use serde_derive::{Deserialize, Serialize}; +-use serde_json; +-use std::io::BufRead; +-use std::sync::{Arc, RwLock}; +-use varlink::{self, CallTrait}; +- +-#[allow(dead_code)] +-#[derive(Clone, PartialEq, Debug)] +-pub enum ErrorKind { +- Varlink_Error, +- VarlinkReply_Error, +- InternalError(Option), +-} +-impl ::std::fmt::Display for ErrorKind { +- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { +- match self { +- ErrorKind::Varlink_Error => write!(f, "Varlink Error"), +- ErrorKind::VarlinkReply_Error => write!(f, "Varlink error reply"), +- ErrorKind::InternalError(v) => { +- write!(f, "info.nispor.InternalError: {:#?}", v) +- } +- } +- } +-} +-pub struct Error( +- pub ErrorKind, +- pub Option>, +- pub Option<&'static str>, +-); +-impl Error { +- #[allow(dead_code)] +- pub fn kind(&self) -> &ErrorKind { +- &self.0 +- } +-} +-impl From for Error { +- fn from(e: ErrorKind) -> Self { +- Error(e, None, None) +- } +-} +-impl std::error::Error for Error { +- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +- self.1 +- .as_ref() +- .map(|e| e.as_ref() as &(dyn std::error::Error + 'static)) +- } +-} +-impl std::fmt::Display for Error { +- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { +- std::fmt::Display::fmt(&self.0, f) +- } +-} +-impl std::fmt::Debug for Error { +- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { +- use std::error::Error as StdError; +- if let Some(ref o) = self.2 { +- std::fmt::Display::fmt(o, f)?; +- } +- std::fmt::Debug::fmt(&self.0, f)?; +- if let Some(e) = self.source() { +- std::fmt::Display::fmt("\nCaused by:\n", f)?; +- std::fmt::Debug::fmt(&e, f)?; +- } +- Ok(()) +- } +-} +-#[allow(dead_code)] +-pub type Result = std::result::Result; +-impl From for Error { +- fn from(e: varlink::Error) -> Self { +- match e.kind() { +- varlink::ErrorKind::VarlinkErrorReply(r) => Error( +- ErrorKind::from(r), +- Some(Box::from(e)), +- Some(concat!(file!(), ":", line!(), ": ")), +- ), +- _ => Error( +- ErrorKind::Varlink_Error, +- Some(Box::from(e)), +- Some(concat!(file!(), ":", line!(), ": ")), +- ), +- } +- } +-} +-#[allow(dead_code)] +-impl Error { +- pub fn source_varlink_kind(&self) -> Option<&varlink::ErrorKind> { +- use std::error::Error as StdError; +- let mut s: &dyn StdError = self; +- while let Some(c) = s.source() { +- let k = self +- .source() +- .and_then(|e| e.downcast_ref::()) +- .and_then(|e| Some(e.kind())); +- if k.is_some() { +- return k; +- } +- s = c; +- } +- None +- } +-} +-impl From<&varlink::Reply> for ErrorKind { +- #[allow(unused_variables)] +- fn from(e: &varlink::Reply) -> Self { +- match e { +- varlink::Reply { +- error: Some(ref t), .. +- } if t == "info.nispor.InternalError" => match e { +- varlink::Reply { +- parameters: Some(p), +- .. +- } => match serde_json::from_value(p.clone()) { +- Ok(v) => ErrorKind::InternalError(v), +- Err(_) => ErrorKind::InternalError(None), +- }, +- _ => ErrorKind::InternalError(None), +- }, +- _ => ErrorKind::VarlinkReply_Error, +- } +- } +-} +-pub trait VarlinkCallError: varlink::CallTrait { +- fn reply_internal_error(&mut self, r#msg: String) -> varlink::Result<()> { +- self.reply_struct(varlink::Reply::error( +- "info.nispor.InternalError", +- Some( +- serde_json::to_value(InternalError_Args { r#msg }) +- .map_err(varlink::map_context!())?, +- ), +- )) +- } +-} +-impl<'a> VarlinkCallError for varlink::Call<'a> {} +-#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +-pub struct InternalError_Args { +- pub r#msg: String, +-} +-#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +-pub struct Get_Reply { +- pub r#net_state: NetState, +-} +-impl varlink::VarlinkReply for Get_Reply {} +-#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +-pub struct Get_Args {} +-pub trait Call_Get: VarlinkCallError { +- fn reply(&mut self, r#net_state: NetState) -> varlink::Result<()> { +- self.reply_struct(Get_Reply { r#net_state }.into()) +- } +- +- // TODO: Need better stuff +- fn fail(&mut self, msg: &str) -> varlink::Result<()> { +- self.reply_struct(varlink::Reply { +- continues: None, +- error: Some(format!("info.nispor.InternalError: {}", msg).into()), +- parameters: None, +- }) +- } +-} +-impl<'a> Call_Get for varlink::Call<'a> {} +-pub trait VarlinkInterface { +- fn get(&self, call: &mut dyn Call_Get) -> varlink::Result<()>; +- fn call_upgraded( +- &self, +- _call: &mut varlink::Call, +- _bufreader: &mut dyn BufRead, +- ) -> varlink::Result> { +- Ok(Vec::new()) +- } +-} +-pub trait VarlinkClientInterface { +- fn get(&mut self) -> varlink::MethodCall; +-} +-#[allow(dead_code)] +-pub struct VarlinkClient { +- connection: Arc>, +-} +-impl VarlinkClient { +- #[allow(dead_code)] +- pub fn new(connection: Arc>) -> Self { +- VarlinkClient { connection } +- } +-} +-impl VarlinkClientInterface for VarlinkClient { +- fn get(&mut self) -> varlink::MethodCall { +- varlink::MethodCall::::new( +- self.connection.clone(), +- "info.nispor.Get", +- Get_Args {}, +- ) +- } +-} +-#[allow(dead_code)] +-pub struct VarlinkInterfaceProxy { +- inner: Box, +-} +-#[allow(dead_code)] +-pub fn new( +- inner: Box, +-) -> VarlinkInterfaceProxy { +- VarlinkInterfaceProxy { inner } +-} +-impl varlink::Interface for VarlinkInterfaceProxy { +- fn get_description(&self) -> &'static str { +- "interface info.nispor\n\ntype IfaceState (\n name: string,\n iface_type: string,\n state: (UP, DOWN, UNKNOWN),\n mtu: int\n)\n\ntype NetState (\n iface_states: [string]IfaceState\n)\n\n\nmethod Get() -> (net_state: NetState)\n\nerror InternalError(msg: string)\n" +- } +- fn get_name(&self) -> &'static str { +- "info.nispor" +- } +- fn call_upgraded( +- &self, +- call: &mut varlink::Call, +- bufreader: &mut dyn BufRead, +- ) -> varlink::Result> { +- self.inner.call_upgraded(call, bufreader) +- } +- fn call(&self, call: &mut varlink::Call) -> varlink::Result<()> { +- let req = call.request.unwrap(); +- match req.method.as_ref() { +- "info.nispor.Get" => self.inner.get(call as &mut dyn Call_Get), +- m => call.reply_method_not_found(String::from(m)), +- } +- } +-} +diff --git a/src/varlink/npd.rs b/src/varlink/npd.rs +deleted file mode 100644 +index 49e5d9b..0000000 +--- a/src/varlink/npd.rs ++++ /dev/null +@@ -1,51 +0,0 @@ +-use libc::umask; +-use nispor::NetState; +-use std::process::exit; +-use varlink::{ListenConfig, VarlinkService}; +- +-use crate::info_nispor::*; +- +-mod info_nispor; +- +-fn print_usage(program: &str) { +- println!("Usage: {} ", program); +-} +- +-fn main() { +- let args: Vec<_> = std::env::args().collect(); +- if args.len() <= 1 { +- print_usage(&args[0]); +- exit(1); +- } +- run_server(&args[1]).unwrap(); +- exit(0); +-} +- +-struct MyInfoGrisgeNispor {} +- +-impl VarlinkInterface for MyInfoGrisgeNispor { +- fn get(&self, call: &mut dyn Call_Get) -> varlink::Result<()> { +- match NetState::retrieve() { +- Ok(s) => call.reply(s), +- Err(e) => call.fail(&e.msg), +- } +- } +-} +- +-fn run_server(address: &str) -> varlink::Result<()> { +- let my_varlink_iface = info_nispor::new(Box::new(MyInfoGrisgeNispor {})); +- let service = VarlinkService::new( +- "info.nispor", +- "Network status query service", +- "0.1", +- "http://nispor.info", +- vec![Box::new(my_varlink_iface)], +- ); +- // Make sure the socket file been created with permission 0666. +- let old_umask = unsafe { umask(0o111) }; +- varlink::listen(service, &address, &ListenConfig::default())?; +- unsafe { +- umask(old_umask); +- } +- Ok(()) +-} +diff --git a/src/varlink/systemd/nispor.service b/src/varlink/systemd/nispor.service +deleted file mode 100644 +index 134cd88..0000000 +--- a/src/varlink/systemd/nispor.service ++++ /dev/null +@@ -1,10 +0,0 @@ +-[Unit] +-Description=Network Inspector(nispor) varlink service +- +-[Service] +-ExecStart=/usr/bin/npd unix:/run/nispor/nispor.so +-DynamicUser=yes +-RuntimeDirectory=nispor +- +-[Install] +-Also=nispor.socket +diff --git a/src/varlink/systemd/nispor.socket b/src/varlink/systemd/nispor.socket +deleted file mode 100644 +index f7d681b..0000000 +--- a/src/varlink/systemd/nispor.socket ++++ /dev/null +@@ -1,10 +0,0 @@ +-[Unit] +-Description=Network Inspector(nispor) varlink service +-PartOf=nispor.service +- +-[Socket] +-ListenStream=/run/nispor/nispor.so +-SocketMode=0666 +- +-[Install] +-WantedBy=sockets.target +-- +2.29.2 + diff --git a/SPECS/nispor.spec b/SPECS/nispor.spec new file mode 100644 index 0000000..8d7faff --- /dev/null +++ b/SPECS/nispor.spec @@ -0,0 +1,147 @@ +Name: nispor +Version: 1.0.1 +Release: 4%{?dist} +Summary: API for network status querying +License: ASL 2.0 +URL: https://github.com/nispor/nispor +Source: https://github.com/nispor/nispor/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source1: %{name}-%{version}-vendor.tar.xz +Patch0: BZ_1919986-bond-add-support-to-vlan-srcmac-tx-hashing-option.patch +Patch1: BZ_1926941-remove-the-varlink-support.patch +BuildRequires: pkg-config +BuildRequires: python3-devel +BuildRequires: rust-toolset +BuildRequires: systemd-rpm-macros +BuildRequires: systemd-devel + +%description +Unified interface for Linux network state querying. + +%package -n python3-%{name} +Summary: %{summary} +Requires: nispor = %{?epoch:%{epoch}:}%{version}-%{release} +BuildArch: noarch + +%description -n python3-%{name} + +This package contains python3 binding of %{name}. + +%package devel +Summary: %{summary} +Requires: nispor%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} + +%description devel + +This package contains C binding of %{name}. + +%prep +%autosetup -p1 + +# Source1 is vendored dependencies +%cargo_prep -V 1 + +# The cargo_prep will create `.cargo/config` which take precedence over +# `.cargo/config.toml` shipped by upstream which fix the SONAME of cdylib. +# To workaround that, merge upstream rustflags into cargo_prep created one. +_FLAGS=`sed -ne 's/rustflags = "\(.\+\)"/\1/p' .cargo/config.toml` +sed -i -e "s/rustflags = \[\(.\+\), \]$/rustflags = [\1, \"$_FLAGS\"]/" \ + .cargo/config + +%build +make +pushd src/python +%py3_build +popd + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +%install +env SKIP_PYTHON_INSTALL=1 PREFIX=%{_prefix} LIBDIR=%{_libdir} %make_install + +pushd src/python +%py3_install +popd + +%files +%doc AUTHORS CHANGELOG DEVEL.md README.md +%license LICENSE +%{_bindir}/npc +%{_libdir}/libnispor.so.* + +%files -n python3-%{name} +%license LICENSE +%{python3_sitelib}/nispor* + +%files devel +%license LICENSE +%{_libdir}/libnispor.so +%{_includedir}/nispor.h +%{_libdir}/pkgconfig/nispor.pc + +%changelog +* Thu Feb 18 2021 Fernando Fernandez Mancera - 1.0.2-4 +- Remove the varlink support. RHBZ#1926941 + +* Tue Feb 02 2021 Fernando Fernandez Mancera - 1.0.1-3 +- Add support to bond vlan+srcmac tx hashing option. RHBZ#1919986 + +* Fri Nov 13 2020 Gris Ge - 1.0.1-2 +- Upload new cargo vendor tarbal without crates used for windows platform. + +* Tue Nov 10 2020 Fernando Fernandez Mancera - 1.0.1-1 +- Upgrade to 1.0.1 + +* Mon Nov 09 2020 Gris Ge - 1.0.0-1 +- Upgrade to 1.0.0 + +* Mon Oct 19 2020 Gris Ge - 0.6.1-2 +- Rebuild to load the compose settings. + +* Tue Oct 13 2020 Gris Ge - 0.6.1-1 +- Upgrade to 0.6.1 + +* Fri Oct 09 2020 Fernando Fernandez Mancera - 0.6.0-2 +- VXLAN Python fix incorrect destination port + +* Fri Oct 09 2020 Fernando Fernandez Mancera - 0.6.0-1 +- Upgrade to 0.6.0 + +* Sun Sep 20 2020 Gris Ge - 0.5.1-1 +- Upgrade to 0.5.1 + +* Thu Sep 17 2020 Gris Ge - 0.5.0-3 +- Trigger rebuild for CI gating + +* Tue Sep 08 2020 Gris Ge - 0.5.0-2 +- Fix the python3-nispor requirement + +* Fri Sep 04 2020 Gris Ge - 0.5.0-1 +- Upgrade to 0.5.0 + +* Sat Aug 29 2020 Gris Ge - 0.4.0-3 +- Fix the ldconfig + +* Wed Aug 26 2020 Gris Ge - 0.4.0-2 +- Add ldconfig to post and postun scripts + +* Wed Aug 26 2020 Gris Ge - 0.4.0-1 +- Upgrade to 0.4.0 + +* Mon Aug 17 2020 Gris Ge - 0.3.0-2 +- Fix python linux bridge vlan filtering + +* Sun Aug 16 2020 Gris Ge - 0.3.0-1 +- Upgrade to 0.3.0 + +* Tue Aug 11 2020 Gris Ge - 0.2.0-1 +- Upgrade to 0.2.0 + +* Thu Jul 09 2020 Gris Ge - 0.1.1-2 +- Include license and documents + +* Wed Jul 08 2020 Gris Ge - 0.1.1-1 +- Initial build.