openvswitch / ovs-issues

Issue tracker repo for Open vSwitch
10 stars 3 forks source link

how to build openvswitch ipsec with source code? #299

Closed bettswang closed 10 months ago

bettswang commented 10 months ago

Hi, maintainer

I just clone git tree from openvswitch. If I want to install openvswitch ipsec with source code(not with .rpm or .deb package), is that possible? I mean installing ipsec function with "./configure".

igsilya commented 10 months ago

Just use make install as usual.

bettswang commented 10 months ago

You mean I can set up ovs-ipsec process on manual way. Just like /usr/bin/python3 /usr/share/openvswitch/scripts/ovs-monitor-ipsec --pidfile=/var/run/openvswitch/ovs-monitor-ipsec.pid --ike-daemon=strongswan --log-file --detach --monitor unix:/var/run/openvswitch/db.sock?

bettswang commented 10 months ago
root@ubuntu2204:~# /usr/bin/python3 /usr/local/share/openvswitch/scripts/ovs-monitor-ipsec --pidfile=/usr/local/var/run/openvswitch/ovs-monitor-ipsec.pid --ike-daemon=strongswan --log-file --detach --monitor unix:/usr/local/var/run/openvswitch/db.sock
Traceback (most recent call last):
  File "/usr/local/share/openvswitch/scripts/ovs-monitor-ipsec", line 25, in <module>
    import ovs.daemon
ModuleNotFoundError: No module named 'ovs'
bettswang commented 10 months ago

After installing ovs module , strongswan,libreswan, I do the command as ahead. It's so strange. Why does the script search the vswitch.ovsschema on the path /usr/share/openvswitch/? I build the ovs without --prefix(just ./configure && make install),so the right path is /usr/local/share/openvswitch/. On the other hand, use apt install openvswitch-ipsec results reverse. See #301

root@ubuntu2204:~# /usr/bin/python3 /usr/local/share/openvswitch/scripts/ovs-monitor-ipsec --pidfile=/usr/local/var/run/openvswitch/ovs-monitor-ipsec.pid --ike-daemon=strongswan --log-file --detach --monitor unix:/usr/local/var/run/openvswitch/db.sock
2023-09-08T05:38:24Z |  0  | ovs-monitor-ipsec | INFO | Restarting IKE daemon
2023-09-08T05:38:24Z |  1  | ovs-monitor-ipsec | INFO | Restarting StrongSwan
Redirecting to: systemctl restart ipsec.service
Job for ipsec.service failed because the control process exited with error code.
See "systemctl status ipsec.service" and "journalctl -xeu ipsec.service" for details.
2023-09-08T05:38:25Z |  2  | ovs-monitor-ipsec | ERR | traceback
Traceback (most recent call last):
  File "/usr/local/share/openvswitch/scripts/ovs-monitor-ipsec", line 1382, in <module>
    main()
  File "/usr/local/share/openvswitch/scripts/ovs-monitor-ipsec", line 1330, in main
    schema_helper = ovs.db.idl.SchemaHelper()
  File "/usr/local/lib/python3.10/dist-packages/ovs/db/idl.py", line 2281, in __init__
    schema_json = ovs.json.from_file(location)
  File "/usr/local/lib/python3.10/dist-packages/ovs/json.py", line 61, in from_file
    stream = open(name, "r")
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/openvswitch/vswitch.ovsschema'
bettswang commented 10 months ago

@igsilya Would you have any idea about this issue?

igsilya commented 10 months ago

After installing ovs module

How did you install the python module in this case? Was it python3-openvswitch package from your distribution or installed via pip install ?

bettswang commented 10 months ago

there are two scenarios:

  1. I install openvswitch with git source code. I didn't install python3-openvswitch separately. The error is "No such file or directory: '/usr/share/openvswitch/vswitch.ovsschema'". But I make install without prefix. The correct path is /usr/local/share/openvsitch/vswitch.ovsschema.
  2. I install openvswitch with apt install openvswitch-ipsec. The dependencies package are openvswitch-common , openvswitch-switch, python3-openvswitch. The error is "No such file or directory: '/usr/local/share/openvswitch/vswitch.ovsschema'". The python3-openvswitch is from the system distrbution. And the correct path is /usr/share/openvsitch/vswitch.ovsschema.
bettswang commented 10 months ago

Additions to scenarios 1 : I install python ovs module with pip install ovs

bettswang commented 10 months ago

Hi, Igsilya I understood what you mean. Scenarios1 was sloved by setting the prefix while installing the ovs with source code. The ovs module of python3 has wrong dir related with installed openvswitch. So I change the dir when installing the ovs. And then python3-openvswitch package maybe also has wrong configuration with ovs at scenarios2.

./configure --prefix=/usr --localstatedir=/var --sysconfig=/etc