2024年9月20日 星期五
Useful Git command
### 1. Fetch all remote branches
```shell
git fetch origin
```
### 2. Pull update to local branch
```bash
git pull origin main --rebase --autostash
```
### 3. Rebase other branch to main branch
```bash
# checkout to main branch
git checkout main
git rebase xxx
```
### 4. Show branchs
``` bash
# show local branch
git branch
# show remote branch
git branch -a
```
### 5. Create branch
``` bash
git branch
```
### 6. Switch branch
``` bash
git checkout
```
### 7. Commit code change
``` bash
# In one line.
git commit -m
# Add commit message from file
git commit -F
# Edit commit message with editor
git commit -a
```
### 8. Revert
``` bash
#Reset
git reset HEAD # 還原 "指定" 的檔案狀態
git reset HEAD # 還原 "全部" 的檔案狀態
#Checkout
git checkout -- # 還原 "指定" 的檔案狀態
git checkout # 還原 "全部" 的檔案狀態
```
### 9. Compare
``` bash
# compare difference
git diff
# show difference file
git status
```
### 10. Push
``` bash
# first time
git push -u origin
# normal
git push
# force
git push -f
```
Append ccflag in yocto bbfile
Could append ccfllag with define flag which wanna to append like following
```bash
# CFLAGS_append_{actived_machine_name} = "-DHT_QCA_WIFI "
CFLAGS_append_chita-clr = "-DHT_QCA_WIFI "
```
2024年3月18日 星期一
【拆雷實錄】fragmeted IP 封包追蹤
最近在Trace fragmeted IP 封包無法被原本程式加的rule "-A INPUT -f -j DROP"阻擋,原因是他是加在input表,其優先權是低於raw表,順序是在defrag之後,這時被切割的packet已經經過defrag重組完,所以無法match fragmented的flag,所以按下面這篇文章需要將rule加在raw表,因為raw表的優先權比defrag高。
[https://blog.csdn.net/caofengtao1314/article/details/120047179](https://blog.csdn.net/caofengtao1314/article/details/120047179)
更改過的rule指令會像是這樣
```bash
iptables -t raw -I PREROUTING -i erouter0 -f -j DROP
# 打LOG方便追蹤
iptables -t raw -I PREROUTING -i erouter0 -f -j LOG --log-prefix "[ATK] IP fragmented" --log-level 1
```
理論上改成這樣就OK,但在比較後面的kernel版本變得比較複雜,defrag變得比raw表的優先權高,變成就算把上面的rule加到raw表也檔不住,所以按下面這篇文章說明需要在load iptable_raw時傳遞參數
```bash
modprobe iptable_raw raw_before_defrag=1
```
[https://serverfault.com/questions/964072/how-to-block-incoming-ipv6-fragments](https://serverfault.com/questions/964072/how-to-block-incoming-ipv6-fragments)
而如果是builtin的kernel module,則需要透過Bootloadert傳遞參數或定義Kernel command line(CONFIG_CMDLINE)在Kernel config,在我的情況是第二種builtin的kernel module,然後在不更改Bootloader的前提,所以我需要加Kernel command line
```ini
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="raw_before_defrag=1"
```
2024年3月12日 星期二
【拆雷實錄】ping 8.8.8.8 data length問題
最近遇到busybox ping 8.8.8.8的怪問題,當ping的data length > 88就ping不通,後面根據google的一篇文章,修改unpack function,拿掉datalen的檢查就OK了。
## 程式碼
[https://gist.github.com/JeffTsengTwn/439e7660958709b388c9cc7eeabc21fb#file-ping-c](https://gist.github.com/JeffTsengTwn/439e7660958709b388c9cc7eeabc21fb#file-ping-c)
訂閱:
文章 (Atom)