Matt Jan

@zoo868e

Joined on Sep 15, 2019

  • 感謝朋友 W 的幫忙,在 mock interview 時我常常會崩潰,但 W 都會情緒穩定的開導我。也感謝家人跟女朋友的鼓勵及支持。 Timeline D+0 Recruiter Call D+18 中文 Coding interview D+19 Received interview feedback D+53 英文 Coding interview + 中文 embedded interview + 中文 Coding interview D+59 通知安排 G&L 面試時程 D+63 中文 G&L interview D+67 通知完成所有面試
     Like 4 Bookmark
  • 第1章討論了 Linux 核心網絡子系統的角色及其運作的三個層次。Netlink socket 介面首次出現在 2.2 版的 Linux 核心中,作為 AF_NETLINK socket。它被創建為比笨拙的 IOCTL 通訊方法更靈活的替代方案。IOCTL 處理程序無法從核心向用戶空間發送非同步消息,而 netlink sockets 則可以。使用 IOCTL 還有另一層複雜性:需要定義 IOCTL 編號。Netlink 的操作模型相當簡單:使用者在 userspace 使用 socket API 打開並註冊一個 netlink socket,這個 netlink socket 處理與核心 netlink socket 的雙向通信,通常用於發送消息來配置各種系統設置並從核心獲取回應。 本章描述了 netlink 協議的實現和 API,並討論了其優缺點。本書還介紹了新的通用 netlink 協議,討論了其實現和優點,並給出了一些使用 libnl 庫的示例。最後,討論了 socket 監控介面。 The Netlink Family Netlink 協定是一個基於 Linux Netlink as an IP Services Protocol 的 Inter Process Communication(IPC) 機制。它提供核心跟核心或核心跟使用者雙向的溝通頻道。該協定的實作主要在下列四個檔案中。 af_netlink.c: 負責提供該協定的 API af_netlink.h genetlink.c: 負責提供易於操作 netlink 訊息的 API diag.c: 負責取得 netlink sockets 資訊的 API,主要用於監控 netlink socket 的運作
     Like  Bookmark
  • 本章將重點介紹位於 ISO 模型第7層的 ICMP 協定,並詳細解析該協定的數據包在系統內核中的處理過程。在用戶空間層面,使用者能夠通過 socket API 來傳送 ICMP 數據包,其中,ping 命令是一個廣為人知且常用的例子。 建議讀者先閱讀 RFC 792 再閱讀本章。 ICMPv4 ICMPv4 訊息主要可以分為兩個類型: RFC 1812 中列出 ICMP 支援的各種訊息類別以及其功能 Error message Information message :::info
     Like  Bookmark
  • source: Steven Rostedt - Learning the Linux Kernel with tracing Hello World Source code #include <stdio.h> int main() {printf("Hello World %p!\n", main);} Compile it
     Like  Bookmark
  • This book introduce the implementation of the network stack in Linux Kernel. Chapter 2: Netlink Chapter 3: Internet Control Message Protocol(ICMP) Chapter 4: IPv4 Chapter 5: The IPv4 Routing Subsystem Chapter 6: Advanced Routing Chapter 7: Linux Neighbouring Subsystem Chapter 8: IPv6 Chapter 9: Netfilter
     Like  Bookmark
  • 常用單一按鍵 i : insert a : append o : open c : change s : substitute y : yank d : delete p : paste r : replace
     Like  Bookmark
  • 建議直接閱讀FirstKernelPatch 花了兩天的時間按照FirstKernelPatch的步驟做了一遍後,成功的提交patch,本文希望讓不得其門而入的開發者,可以更容易的加入貢獻Linux Kernel的行列。 建議本文讀者使用過Unix-like作業系統,且熟悉shell操作 事前準備 由於我是直接使用 Ubuntu 做測試,因此若使用虛擬機或不同發行版本,所使用的指令以及結果會不盡相同。 一部Ubuntu主機
     Like 2 Bookmark
  • contributed by < zoo868e > 開發環境 $ uname -a Linux mattjan 5.15.0-92-generic #102-Ubuntu SMP Wed Jan 10 09:33:48 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux $ gcc --version gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 指定佇列的操作 通過 make test 的所有測試。
     Like  Bookmark
  • Introduction 由於計時攻擊的興起,作者提到下列不同的工具可以確認執行原始碼時,是否為常數時間。但是這些工具都需要建立硬體模型,這不是個簡單的任務,尤其CPU製造商不會公布太多CPU的硬體細節。因此提出dudect,利用旁道攻擊的概念,透過統計分析運行時間是否為常數時間。這樣的方法就無需建立硬體模型並且可以運行在每一個不同的硬體上。 ctgring: Valgrind的擴充功能 Flow-tracker ctverif 方法 簡而言之,本論文提供了一種可以偵測出程式是否洩漏運行時間的方法
     Like  Bookmark
  • While examining the implementation of ping in Linux, I noticed that sk_for_each is essentially hlist_for_each_entry, leading me to discover the use of such an expression in hlist_for_each_entry_safe. #define hlist_for_each_entry(pos, head, member) \ for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ pos; \ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) #define hlist_for_each_entry_safe(pos, n, head, member) \ for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\ pos && ({ n = pos->member.next; 1; }); \
     Like  Bookmark
  • 近期在閱讀由Jserv撰寫的Linux 核心原始程式碼巨集: max, min時發現最新版本的max, min已經改變了實作方式,所以本篇記錄了在閱讀前人筆記時遇到的問題以及新的實作方式我注意到的細節。 #define __is_constexpr(x) \ (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) #define __typecheck(x, y) \ (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) #define __no_side_effects(x, y) \ (__is_constexpr(x) && __is_constexpr(y))
     Like  Bookmark
  • 測驗$\alpha-1$ st_rotate_left: 旋轉左子樹變平衡 st_rotate_right: 旋轉右子樹變平衡 st_balance: 左子樹高度-右子樹高度 st_max_hint: 樹的高度 st_update: st_balance < -1,代表右子樹太重,所以要st_rotate_right,反之,要st_rotate_left。在st_update的最後會檢查hint是否改變,若是改變,親代的hint就可能改變,因此要向上更新。另外,由於rotate的操作只有在update中會發生,所以也只有在st_update中需要更新hint st_insert: 需要提供root, parent, node和dir。root是整棵樹的根,parent代表node的親代,dir則代表node是在parent的左邊還是右邊。實作方法直觀,將node附值給parent的dir,將parent設為node的親代,st_update樹的parent這個節點,因為可能需要rotate,這會更新整棵樹。 st_replace_[left/right]: 用l/r節點覆寫n節點 st_remove: 刪除節點del。如果有右子樹會先用右子樹的最小值複寫del,若沒有右子樹則會用左子樹的最大值覆寫del。若沒有子樹則直接刪除即可。當我們把least/most節點移動到del時,我們需要更新他原本的親代的hint,同時,如果因為移動導致不平衡,需要旋轉成平衡子樹。
     Like  Bookmark
  • First of all, download the latest version of uftrace from github. Since the version in WSL2 is 0.9.4 which haven't fix the Segmentation Fault bug. How to use? Prepare the executable file Record it Report it Prepare the executable file When compiling the project, must have the -pg flag in every gcc command if it contain the source file.
     Like  Bookmark
  • This note explains how to squash commits in Git. If you find any incorrect information, kindly correct it. Additionally, please feel free to ask any questions or leave comments if you encounter any issues. Why we need to sqush the commit When trying to resolve project issues, sometimes you need to commit multiple versions to record the work log. After sending the PR, the changes may not comply with the contribution rules, and you have to fix them. As a result, you end up with numerous commits that don't pertain to this particular PR, but only reflect your work log. The project owner likely wants to concentrate on the final changes you made, rather than your work log. To address this, we need to squash the commits. How to squash the commit Given the git log shown below, I want to squash the commits after upstream/master into one commit.
     Like  Bookmark
  • jserv/shecc, ISSUE#7, PR Development enviroment > uname -a Linux zoo868e 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux > gcc --version gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0 Problem Statement In issue #7, reborn2266 used uftrace to analyze the shecc project and found that the strcmp() function is consuming the most execution time in shecc. This is because the find_ function, such as find_func, uses strcmp to check if a function has been declared. Currently, shecc compares each inserted name every time until it finds a match or determines that it hasn't been inserted. reborn2266 suggested that we can enhance the search performance by utilizing a trie data structure to store the inserted names.
     Like  Bookmark
  • I am new to the Rust programming language, and I would like to share the notes on a problem I encountered and the solution I found. At first, I attempted to use the winapi library in my Rust project. However, despite following the documentation, I encountered difficulties importing it. Additionally, it appears that the project is no longer actively maintained. Hence, I have decided to utilize the crate provided by Microsoft for my needs. Windows crates The crate that provide by Microsoft called windows-rs, you can find it on github. How to import
     Like  Bookmark
  • Please read this post if you are familiar with the English. 這篇筆記是記錄我在C:容量不夠時,尋找移動WSL到D:的方法,詳情請參考上面那篇貼文。 Step 1 輸出原本的WSL,這裡的DistributionName可以透過wsl -l -v獲得,Tar-FileName就任意以tar為副檔名的名稱都可以。在FileName前面可以加上路徑,如果要指定D:就在前面加上D:\ wsl.exe --export <DistirbutionName> <Tar-FileName> Step 2 把輸出的tar輸入到新的一個WSL中,一樣透過powershell(Admin)操作。 NewDistributionName: 可以是任意名稱,可以當作你幫你的WSL取的名字
     Like  Bookmark
  • This article serves as a record of my recent work. If you notice any errors or have any feedback, please leave a message. It's important to note that the 3rd party function codes mentioned, such as disk_info or remaining_time, are provided as examples and may not guarantee correctness or compilability. These functions are intended to demonstrate certain concepts or serve as starting points for further development. It's essential to review and adapt them according to the specific requirements and environment of your project. Hows it looks like at first? The Structure This structure is aims to provide the disk information and the battery information. struct SystemInformation{ used_disk: u32,
     Like  Bookmark
  • tags: C++17 cppreference Structured binding 的宣告有以下三種 attr(optional) cv-auto ref-qualifier(optional) [identifier-list] = expression; attr(optional) cv-auto ref-qualifier(optional) [identifier-list]{expression}; attr(optional) cv-auto ref-qualifier(optional) [identifier-list](expression); Description: attr: 標籤的序列,詳見cppreference
     Like  Bookmark
  • 本篇內容是我看Sockets Tutorial時所寫下的筆記,可以直接下載他的server.c, client.c執行看結果 gcc -o server server.c gcc -o client client.c ./server 12345 # 切到令一個terminal ./client 127.0.0.1 12345 Day 1 Hello World, only trace the server side Knowledge
     Like  Bookmark