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 [crayon-651853b5eb58f895369913/] We can […]

  • 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 標記。 [crayon-651853b5eb9e1083932304/]   查了一下,原因是因為沒有啟用 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 的時候,過一陣子會出現這個錯誤: [crayon-651853b5ebb43185151272/] 一陣搜尋後, 其中一個方法是調整 sysctl 的參數,沒用。 修改 net.ipv4.xfrm4_gc_thresh=999999,沒用。 來自 netfilter 的說明: 來自 netfilter 說明:這代表 kernel-side 的 netlink socker buffer 沒有空間了。因此 user-space 的程式沒有辦法處理來自 kernel 的資料。 有三種解法,1) 把 buffer size 透過 /proc/sys/net/core, sysctl 加大,或是使用 SO_RCVBUF file descriptor。2) 加快處理端的處理速度。3) 如果不需要太大的 buffer,嘗試把 buffer […]

  • 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 就不會出現問題。 接著出現了這樣的訊息: [crayon-651853b5ebce7933488894/] 搜尋之後,有說確認 iw list 的 frequencies 是否有支援的,我這邊看是有: [crayon-651853b5ebced653844230/] 重新嘗試一遍還是出現相同的問題,換 country code 為 JP 或是 TW 依然不行。 繼續搜尋,看到 iw reg get,可以看到目前的 country code 有關頻譜的設定/規定: [crayon-651853b5ebcf0312871711/]   我疑惑的點在於,iw list 的 frequencies 已經沒有出現 no IR 的字眼了,應該就要能夠使用於 AP mode,但找一找看到這篇 […]

  • 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 的整個結構為: [crayon-651853b5ebeec697013337/] 可以看到,除了前四個 member 外,最後還定義了一個 drv_priv,這是用來指向各個 driver 的 private data 的 member。以 ath9k 為例,這邊是指向一個 struct ath_atx_tid,ath10k 則是 struct ath10k_txq。 以 ath9k 為例,這邊是在 sta_info_alloc 的地方 allocated: […]