Category: Linux

  • Using OpenConnect for UNC-CH VPN on Linux

    I don’t have good luck with UNC-Chapel Hill’s VPN installation guide for Linux systems (KB0010220, login required). After several tests with Cisco AnyConnect provided in the KB post, they all end up with the following message: $ sudo /opt/cisco/anyconnect/bin/vpn connect vpn.unc.edu >> error: The service provider in your current location is restricting access to the…

  • NGINX 設定 WebDAV (HTTPS + Authentication)

    為了能夠自由的同步 Zotero 中的論文,我們可以透過 WebDAV 來同步電腦中的論文到雲端上。以下分為四個步驟介紹如何在 Ubuntu 使用 NGINX 設定帶有 HTTPS、Auth 的 WebDAV 功能。 A. 安裝與設定 NGINX 安裝 nginx-full (dep: libnginx-mod-http-dav-ext) $ apt install nginx-full 加入 WebDAV 設定檔 $ sudo nano /etc/nginx/sites-available/webdav.conf $ cd /etc/nginx/sites-enabled $ ln -s ../sites-available/webdav.conf . webdav.conf 內容 如果你要使用 domain name,請在 listen 前面補上 server_name server_name your-webdav-domain.com; B. 測試 NGINX WebDAV (w/o HTTPS/Authentication)…

  • Building, Debugging, Developing GNOME VTE Terminal

    Gnome Vte is a virtual terminal widget for GTK+ applications. It is used in various GTK+ applications, such as Guake, lxterminal, qemu, remmina, terminator…etc. Its a well done infrastructure library, but with poor documentation about how to building, debugging, and developing this library. Here are some notes to fill the gap. Building $ git clone…

  • cflow support main start from static function patch

    https://gist.github.com/calio/8f7278394d0125814580 *but* this will cause some error when main start from normal function. (you will need to rebuild the cflow without this patch)  

  • The packet flow, from userspace to kernel driver in Linux network stack

    這是一個想要從 userspace 一直深入到 driver,理解 Linux packet 究竟如何運行的流程圖。 我在交大做的東西都在 driver space,使用 ath9k/ath10k 做實驗。我所理解的是 ath9k 上面對著 mac80211 (Linux 的 softmac),也就是說,driver 在功能上,只需要實做`struct ieee80211_ops` 的功能即可。主要都在處理 `.wake_tx_queue` 的功能。 對於他之上,頂多知道 ieee80211_queue_skb 最後會 call drv_wake_tx_queue 然後根據  driver 不同呼叫不同 driver 的實做,以 ath9k 而言就是 ath9k_wake_tx_queue。 還是想要知道一下,究竟這個 packet 是如何被傳入 mac80211 這層,順便解答一個以前問自己的問題「wireshark 抓封包時究竟是從那一層抓的」。 使用兩種工具,一個是 cflow、一個是 pycflow2dot。前者用來描述 call graph,後者拿來轉成 graphviz 的 dot 語言並且輸出 svg。兩者都有做修改,cflow 的部份請參考備註的部份,pycflow2dot 請參考我修改的版本: mlouielu/pycflow2dot。…

  • iptables not work on bridge network

    最近遇到一個問題是,iptables 在 bridge network 上不會有效果。測試的方式是在 mangle 上把特定 source ip 的 packet 壓上 dscp 標記。 sudo iptables -t mangle -A FORWARD -s 192.168.7.222 -j DSCP –set-dscp-class cs7   查了一下,原因是因為沒有啟用 br_netfilter 這個 module, 自 4.x 版的 Linux 將 bridge filter 的功能移出來。使用 modprobe br_netfilter 將 module 載入即可。

  • netlink: No buffer space available

    問題在於 kernel buffer 不足。 http://lists.netfilter.org/pipermail/netfilter/2007-February/067929.html 解法: echo 500000 > /proc/sys/net/core/rmem_max  

  • Python socket OSError: [Errno 105] No buffer space available

    今天在處理 netlink 的時候,使用 Python 當作 user-space 承接來自 kernel-space 訊息的工具。我的情況是大約每 10ms 會由 kernel-space 發起一次 netlink multicast 到 user-space。當在運行 user-space script 的時候,過一陣子會出現這個錯誤: Traceback (most recent call last): File “measure_netlink.py”, line 33, in <module> b = sock.recvfrom(NETLINK_BUF_LENGTH)[0] OSError: [Errno 105] No buffer space available 一陣搜尋後, 其中一個方法是調整 sysctl 的參數,沒用。 修改 net.ipv4.xfrm4_gc_thresh=999999,沒用。 來自 netfilter 的說明: 來自 netfilter 說明:這代表 kernel-side 的…

  • hostapd: Using DFS channel in AP mode (ath9k)

    今天在設定 hostapd 給 ath9k 的網卡使用時,遇到了這樣的問題: 無法在 AP mode 設定 channel 為 120, 124, 132 首先出現的是 DFS start_dfs_cac() failed, -1,照著這篇 mail 安裝 wireless-regdb 以及 crda 就不會出現問題。 接著出現了這樣的訊息: ➜ hostapd git:(master) ✗ sudo ./hostapd nems.conf Configuration file: nems.conf wlp0s20f0u5: interface state UNINITIALIZED->COUNTRY_UPDATE Channel 120 (primary) not allowed for AP mode wlp0s20f0u5: IEEE 802.11 Configured channel (120) not found from the channel…

  • TIL: private data struct in Linux kernel

    在 Linux kernel 當中有許多的 common struct,例如說 ieee80211_txq 這樣的結構,透過這樣的方式,可以讓不同的 driver 重用相同的 struct。但是,針對每個不同的 driver,還是會有不同的 private data,這時候就會用 private data struct 的方式來處理。 例如說,struct ieee80211_txq 是 mac80211 中的 intermediate tx queue,目前有使用的 wireless driver 為 ath9k, ath10k 以及 mt76。struct ieee80211_txq 的整個結構為: /** * struct ieee80211_txq – Software intermediate tx queue * * @vif: &struct ieee80211_vif pointer from the add_interface callback. * @sta: station table…